]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: lib/mpi - use min() instead of min_t()
authorDavid Laight <david.laight.linux@gmail.com>
Wed, 19 Nov 2025 22:41:33 +0000 (22:41 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 24 Nov 2025 09:44:14 +0000 (17:44 +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>
lib/crypto/mpi/mpicoder.c

index 47f6939599b33a7e6fdd2a3055c0bb5c82ee2b14..bf716a03c7045ef5ef6f14278d186a42c798ede0 100644 (file)
@@ -398,7 +398,7 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes)
 
        while (sg_miter_next(&miter)) {
                buff = miter.addr;
-               len = min_t(unsigned, miter.length, nbytes);
+               len = min(miter.length, nbytes);
                nbytes -= len;
 
                for (x = 0; x < len; x++) {