]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: aesni - ctr_crypt() use min() instead of min_t()
authorDavid Laight <david.laight.linux@gmail.com>
Wed, 19 Nov 2025 22:41:06 +0000 (22:41 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 24 Nov 2025 09:43:40 +0000 (17:43 +0800)
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>
arch/x86/crypto/aesni-intel_glue.c

index d953ac470aae34d3337ea39b4cef7151164cf555..f71db4f1c99c815644a1e10dc4a819568402d708 100644 (file)
@@ -693,8 +693,7 @@ ctr_crypt(struct skcipher_request *req,
                         * operation into two at the point where the overflow
                         * will occur.  After the first part, add the carry bit.
                         */
-                       p1_nbytes = min_t(unsigned int, nbytes,
-                                         (nblocks - ctr64) * AES_BLOCK_SIZE);
+                       p1_nbytes = min(nbytes, (nblocks - ctr64) * AES_BLOCK_SIZE);
                        (*ctr64_func)(key, walk.src.virt.addr,
                                      walk.dst.virt.addr, p1_nbytes, le_ctr);
                        le_ctr[0] = 0;