linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: fix potential null pointer dereference on pointer dd
@ 2021-10-30 13:35 Chengfeng Ye
  2021-11-20  4:27 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Chengfeng Ye @ 2021-10-30 13:35 UTC (permalink / raw)
  To: herbert, davem, nicolas.ferre, alexandre.belloni, ludovic.desroches
  Cc: linux-kernel, 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.

Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
---
 drivers/crypto/atmel-sha.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c
index 1b13f601fd95..f6ea5aadb86a 100644
--- a/drivers/crypto/atmel-sha.c
+++ b/drivers/crypto/atmel-sha.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: fix potential null pointer dereference on pointer dd
  2021-10-30 13:35 [PATCH] crypto: fix potential null pointer dereference on pointer dd Chengfeng Ye
@ 2021-11-20  4:27 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-11-20  4:27 UTC (permalink / raw)
  To: Chengfeng Ye
  Cc: davem, nicolas.ferre, alexandre.belloni, ludovic.desroches, linux-kernel

On Sat, Oct 30, 2021 at 06:35:56AM -0700, Chengfeng Ye wrote:
> 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.
> 
> Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
> ---
>  drivers/crypto/atmel-sha.c | 3 +++
>  1 file changed, 3 insertions(+)

You forgot to cc linux-crypto.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-20  4:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-30 13:35 [PATCH] crypto: fix potential null pointer dereference on pointer dd Chengfeng Ye
2021-11-20  4:27 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).