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

crypto: ccp - 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
14ca8ce1 0f8ead58

+1 -1
+1 -1
drivers/crypto/ccp/ccp-dev.c
··· 507 507 { 508 508 struct ccp_device *ccp = container_of(rng, struct ccp_device, hwrng); 509 509 u32 trng_value; 510 - int len = min_t(int, sizeof(trng_value), max); 510 + int len = min(sizeof(trng_value), max); 511 511 512 512 /* Locking is provided by the caller so we can update device 513 513 * hwrng-related fields safely