[PATCH] crypto: atmel-sha: reject initialization without a device

Slavin Liu posted 1 patch 1 week, 4 days ago
drivers/crypto/atmel-sha.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] crypto: atmel-sha: reject initialization without a device
Posted by Slavin Liu 1 week, 4 days ago
A transform may be initialized for the first time after the last
device has been removed from the driver list. Return -ENODEV when the
lookup is empty, before the debug message reads dd->dev.

Detected by static analysis and reviewed with AI-assisted source auditing.

Fixes: ebc82efa1cd6 ("crypto: atmel - add Atmel SHA1/SHA256 driver")
Assisted-by: LLM
Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
---
 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 48f54b615504..d2338e731d56 100644
--- a/drivers/crypto/atmel-sha.c
+++ b/drivers/crypto/atmel-sha.c
@@ -422,6 +422,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 -ENODEV;
+
 	ctx->dd = dd;
 
 	ctx->flags = 0;
Re: [PATCH] crypto: atmel-sha: reject initialization without a device
Posted by Herbert Xu 1 week ago
Slavin Liu <bolin.liu@seu.edu.cn> wrote:
> A transform may be initialized for the first time after the last
> device has been removed from the driver list. Return -ENODEV when the
> lookup is empty, before the debug message reads dd->dev.
> 
> Detected by static analysis and reviewed with AI-assisted source auditing.
> 
> Fixes: ebc82efa1cd6 ("crypto: atmel - add Atmel SHA1/SHA256 driver")
> Assisted-by: LLM
> Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
> ---
> drivers/crypto/atmel-sha.c | 3 +++
> 1 file changed, 3 insertions(+)

Patch applied.  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