crypto: caam: Add check for kcalloc() in test_len()
Subsystems (3)
PATCH 1/1 crypto: caam: Add check for kcalloc() in test_len()
As kcalloc() may fail, check its return value to avoid a NULL pointer dereference when passing the buffer to rng->read() and print_hex_dump_debug().
Fixes 2be0d806e25e ("crypto: caam - add a test for the RNG")
Signed-off-by Guangshuo Li <[email protected]>
--- drivers/crypto/caam/caamrng.c | 1 - 1 file changed, 1 deletion(-)
drivers/crypto/caam/caamrng.c +0 -1
@@ -183,7 +183,6 @@ static inline void test_len(struct hwrng *rng, size_t len, bool wait) buf =kcalloc (CAAM_RNG_MAX_FIFO_STORE_SIZE ,sizeof (u8),GFP_KERNEL );if (!buf) { -dev_err (dev,"RNG buffer allocation failed\n" );return ; }while (len >0 ) {
Signature · 1 line
2.43.0
Greg KH
maintainerQuoted 3 lines · Guangshuo Li
As
kcalloc()may fail, check its return value to avoid a NULL pointer dereference when passing the buffer torng->read()andprint_hex_dump_debug().
But that is not what this patch does :(
Quoted 2 lines
Fixes 2be0d806e25e ("crypto: caam - add a test for the RNG")
No need for stable here.
Quoted 10 lines
Signed-off-by Guangshuo Li <[email protected]>--- drivers/crypto/caam/caamrng.c | 1 - 1 file changed, 1 deletion(-)drivers/crypto/caam/caamrng.c +0
-0
drivers/crypto/caam/caamrng.c static inline void test_len(struct hwrng *rng, size_t len, bool wait) · line 187
Quoted 6 lines
drivers/crypto/caam/caamrng.c +0
-1@@ -183,7 +183,6 @@ static inline void test_len(struct hwrng *rng, size_t len, bool wait) buf =kcalloc (CAAM_RNG_MAX_FIFO_STORE_SIZE ,sizeof (u8),GFP_KERNEL );if (!buf) { -dev_err (dev,"RNG buffer allocation failed\n" );return ; }
checkpatch should show that you can remove the { } now, right?
thanks,
greg k-h