Skip to content

Commit a22a231

Browse files
ebiggersherbertx
authored andcommitted
crypto: skcipher - remove redundant clamping to page size
In the case where skcipher_walk_next() allocates a bounce page, that page by definition has size PAGE_SIZE. The number of bytes to copy 'n' is guaranteed to fit in it, since earlier in the function it was clamped to be at most a page. Therefore remove the unnecessary logic that tried to clamp 'n' again to fit in the bounce page. Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 807c801 commit a22a231

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

crypto/skcipher.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ static int skcipher_walk_next(struct skcipher_walk *walk)
250250
slow_path:
251251
return skcipher_next_slow(walk, bsize);
252252
}
253+
walk->nbytes = n;
253254

254255
if (unlikely((walk->in.offset | walk->out.offset) & walk->alignmask)) {
255256
if (!walk->page) {
@@ -259,15 +260,10 @@ static int skcipher_walk_next(struct skcipher_walk *walk)
259260
if (!walk->page)
260261
goto slow_path;
261262
}
262-
263-
walk->nbytes = min_t(unsigned, n,
264-
PAGE_SIZE - offset_in_page(walk->page));
265263
walk->flags |= SKCIPHER_WALK_COPY;
266264
return skcipher_next_copy(walk);
267265
}
268266

269-
walk->nbytes = n;
270-
271267
return skcipher_next_fast(walk);
272268
}
273269

0 commit comments

Comments
 (0)