Skip to contentSkip to conversation

crypto: fix potential null pointer dereference on pointer dd

PATCH In review Chengfeng Ye 2 participants 2 messages Oct 30, 2021 – Nov 20, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: fix potential null pointer dereference on pointer dd

The return pointer of atmel_sha_find_dev could be null, there could be potential null-deref issue. Fix this by adding a null check.

---
 drivers/crypto/atmel-sha.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/crypto/atmel-sha.c +3 -0
index 1b13f601fd95..f6ea5aadb86a 100644
@@ -430,6 +430,9 @@ static int atmel_sha_init(struct ahash_request *req)
 	struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
 	struct atmel_sha_dev *dd = atmel_sha_find_dev(tctx);
 
+	if (!dd)
+		return -EINVAL;
+
 	ctx->dd = dd;
 
 	ctx->flags = 0;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 8 lines · Chengfeng Ye

The return pointer of atmel_sha_find_dev could be null, there could be potential null-deref issue. Fix this by adding a null check.

---
 drivers/crypto/atmel-sha.c | 3 +++
 1 file changed, 3 insertions(+)

You forgot to cc linux-crypto.

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt