[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250922155322.1825714-1-lgs201920130244@gmail.com>
Date: Mon, 22 Sep 2025 23:53:22 +0800
From: Guangshuo Li <lgs201920130244@...il.com>
To: Horia Geantă <horia.geanta@....com>,
Pankaj Gupta <pankaj.gupta@....com>,
Gaurav Jain <gaurav.jain@....com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
"Victoria Milhoan (b42089)" <vicki.milhoan@...escale.com>,
Meenakshi Aggarwal <meenakshi.aggarwal@....com>,
Dan Douglass <dan.douglass@....com>,
linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Guangshuo Li <lgs201920130244@...il.com>,
stable@...r.kernel.org
Subject: [PATCH v2] 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().
Fixes: 2be0d806e25e ("crypto: caam - add a test for the RNG")
Cc: stable@...r.kernel.org
---
changelog:
v2:
- Return -ENOMEM directly on allocation failure.
Signed-off-by: Guangshuo Li <lgs201920130244@...il.com>
---
drivers/crypto/caam/caamrng.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
index b3d14a7f4dd1..357860ee532c 100644
--- a/drivers/crypto/caam/caamrng.c
+++ b/drivers/crypto/caam/caamrng.c
@@ -182,6 +182,9 @@ 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) {
+ return -ENOMEM;
+ }
while (len > 0) {
read_len = rng->read(rng, buf, len, wait);
--
2.43.0
Powered by blists - more mailing lists