Skip to content

Commit 6c5d5b6

Browse files
David Laightherbertx
authored andcommitted
crypto: aesni - ctr_crypt() use min() instead of min_t()
min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 680cd3e commit 6c5d5b6

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

arch/x86/crypto/aesni-intel_glue.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,7 @@ ctr_crypt(struct skcipher_request *req,
693693
* operation into two at the point where the overflow
694694
* will occur. After the first part, add the carry bit.
695695
*/
696-
p1_nbytes = min_t(unsigned int, nbytes,
697-
(nblocks - ctr64) * AES_BLOCK_SIZE);
696+
p1_nbytes = min(nbytes, (nblocks - ctr64) * AES_BLOCK_SIZE);
698697
(*ctr64_func)(key, walk.src.virt.addr,
699698
walk.dst.virt.addr, p1_nbytes, le_ctr);
700699
le_ctr[0] = 0;

0 commit comments

Comments
 (0)