]> Gentwo Git Trees - linux/.git/commitdiff
crypto: ccp - use min() instead of min_t()
authorDavid Laight <david.laight.linux@gmail.com>
Wed, 19 Nov 2025 22:41:12 +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>
drivers/crypto/ccp/ccp-dev.c

index c531d13d971f3f61f97c332972a741aa8fd289c7..246801912e1a5385b9f5e27239233e3371de9e7a 100644 (file)
@@ -507,7 +507,7 @@ int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 {
        struct ccp_device *ccp = container_of(rng, struct ccp_device, hwrng);
        u32 trng_value;
-       int len = min_t(int, sizeof(trng_value), max);
+       int len = min(sizeof(trng_value), max);
 
        /* Locking is provided by the caller so we can update device
         * hwrng-related fields safely