Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH 1/3] crypto: spacc - Fix uninitialized variable in spacc_aead_process()
       [not found] <0c352e73-714a-476e-8e71-eef750f22902@stanley.mountain>
@ 2024-08-15 11:20 ` Dan Carpenter
  2024-08-15 11:20 ` [PATCH 2/3] crypto: spacc - Fix NULL vs IS_ERR() check in spacc_aead_fallback() Dan Carpenter
  2024-08-15 11:20 ` [PATCH 3/3] crypto: spacc - Check for allocation failure in spacc_skcipher_fallback() Dan Carpenter
  2 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-08-15 11:20 UTC (permalink / raw)
  To: Pavitrakumar M
  Cc: Herbert Xu, David S. Miller, shwetar, Ruud Derwig, linux-crypto,
	linux-kernel

Smatch complains that:

    drivers/crypto/dwc-spacc/spacc_aead.c:1031 spacc_aead_process()
    error: uninitialized symbol 'ptaadsize'.

This could happen if, for example, tctx->mode was CRYPTO_MODE_NULL and
req->cryptlen was less than icvremove.

Fixes: 06af76b46c78 ("crypto: spacc - Add SPAcc aead support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/crypto/dwc-spacc/spacc_aead.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/crypto/dwc-spacc/spacc_aead.c b/drivers/crypto/dwc-spacc/spacc_aead.c
index 3468ff605957..50ef9053fc4d 100755
--- a/drivers/crypto/dwc-spacc/spacc_aead.c
+++ b/drivers/crypto/dwc-spacc/spacc_aead.c
@@ -823,7 +823,7 @@ static int spacc_aead_process(struct aead_request *req, u64 seq, int encrypt)
 	u32 dstoff;
 	int icvremove;
 	int ivaadsize;
-	int ptaadsize;
+	int ptaadsize = 0;
 	int iv_to_context;
 	int spacc_proc_len;
 	u32 spacc_icv_offset = 0;
@@ -974,8 +974,6 @@ static int spacc_aead_process(struct aead_request *req, u64 seq, int encrypt)
 	    tctx->mode == CRYPTO_MODE_NULL) {
 		if (req->cryptlen >= icvremove)
 			ptaadsize = req->cryptlen - icvremove;
-	} else {
-		ptaadsize = 0;
 	}
 
 	/* Calculate and set the below, important parameters
-- 
2.43.0


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

* [PATCH 2/3] crypto: spacc - Fix NULL vs IS_ERR() check in spacc_aead_fallback()
       [not found] <0c352e73-714a-476e-8e71-eef750f22902@stanley.mountain>
  2024-08-15 11:20 ` [PATCH 1/3] crypto: spacc - Fix uninitialized variable in spacc_aead_process() Dan Carpenter
@ 2024-08-15 11:20 ` Dan Carpenter
  2024-08-15 11:20 ` [PATCH 3/3] crypto: spacc - Check for allocation failure in spacc_skcipher_fallback() Dan Carpenter
  2 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-08-15 11:20 UTC (permalink / raw)
  To: Pavitrakumar M
  Cc: Herbert Xu, David S. Miller, shwetar, Ruud Derwig, linux-crypto,
	linux-kernel

The crypto_alloc_aead() function doesn't return NULL pointers, it returns
error pointers.  Fix the error checking.

Fixes: 06af76b46c78 ("crypto: spacc - Add SPAcc aead support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/crypto/dwc-spacc/spacc_aead.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/dwc-spacc/spacc_aead.c b/drivers/crypto/dwc-spacc/spacc_aead.c
index 50ef9053fc4d..da9df329f9d4 100755
--- a/drivers/crypto/dwc-spacc/spacc_aead.c
+++ b/drivers/crypto/dwc-spacc/spacc_aead.c
@@ -784,9 +784,9 @@ static int spacc_aead_fallback(struct aead_request *req,
 	ctx->fb.aead = crypto_alloc_aead(aead_name, 0,
 					 CRYPTO_ALG_NEED_FALLBACK |
 					 CRYPTO_ALG_ASYNC);
-	if (!ctx->fb.aead) {
+	if (IS_ERR(ctx->fb.aead)) {
 		pr_err("Spacc aead fallback tfm is NULL!\n");
-		return -EINVAL;
+		return PTR_ERR(ctx->fb.aead);
 	}
 
 	subreq = aead_request_alloc(ctx->fb.aead, GFP_KERNEL);
-- 
2.43.0


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

* [PATCH 3/3] crypto: spacc - Check for allocation failure in spacc_skcipher_fallback()
       [not found] <0c352e73-714a-476e-8e71-eef750f22902@stanley.mountain>
  2024-08-15 11:20 ` [PATCH 1/3] crypto: spacc - Fix uninitialized variable in spacc_aead_process() Dan Carpenter
  2024-08-15 11:20 ` [PATCH 2/3] crypto: spacc - Fix NULL vs IS_ERR() check in spacc_aead_fallback() Dan Carpenter
@ 2024-08-15 11:20 ` Dan Carpenter
  2 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-08-15 11:20 UTC (permalink / raw)
  To: Pavitrakumar M
  Cc: Herbert Xu, David S. Miller, Bhoomika K, Ruud Derwig,
	linux-crypto, linux-kernel

Check for crypto_alloc_skcipher() failure.

Fixes: c8981d9230d8 ("crypto: spacc - Add SPAcc Skcipher support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/crypto/dwc-spacc/spacc_skcipher.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/dwc-spacc/spacc_skcipher.c b/drivers/crypto/dwc-spacc/spacc_skcipher.c
index 488c03ff6c36..8c698b75dd92 100644
--- a/drivers/crypto/dwc-spacc/spacc_skcipher.c
+++ b/drivers/crypto/dwc-spacc/spacc_skcipher.c
@@ -67,6 +67,8 @@ static int spacc_skcipher_fallback(unsigned char *name,
 	tctx->fb.cipher = crypto_alloc_skcipher(name,
 						CRYPTO_ALG_TYPE_SKCIPHER,
 						CRYPTO_ALG_NEED_FALLBACK);
+	if (IS_ERR(tctx->fb.cipher))
+		return PTR_ERR(tctx->fb.cipher);
 
 	crypto_skcipher_set_reqsize(reqtfm,
 				    sizeof(struct spacc_crypto_reqctx) +
-- 
2.43.0


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

end of thread, other threads:[~2024-08-15 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0c352e73-714a-476e-8e71-eef750f22902@stanley.mountain>
2024-08-15 11:20 ` [PATCH 1/3] crypto: spacc - Fix uninitialized variable in spacc_aead_process() Dan Carpenter
2024-08-15 11:20 ` [PATCH 2/3] crypto: spacc - Fix NULL vs IS_ERR() check in spacc_aead_fallback() Dan Carpenter
2024-08-15 11:20 ` [PATCH 3/3] crypto: spacc - Check for allocation failure in spacc_skcipher_fallback() Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox