Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: lib/mpi - 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>

authored by

David Laight and committed by
Herbert Xu
80b61046 14ca8ce1

+1 -1
+1 -1
lib/crypto/mpi/mpicoder.c
··· 398 398 399 399 while (sg_miter_next(&miter)) { 400 400 buff = miter.addr; 401 - len = min_t(unsigned, miter.length, nbytes); 401 + len = min(miter.length, nbytes); 402 402 nbytes -= len; 403 403 404 404 for (x = 0; x < len; x++) {