Skip to contentSkip to conversation

crypto: Fix return value check in aead_crypt()

PATCH In review Wang Qing 3 participants 5 messages Nov 6, 2020 – Nov 20, 2020

Subsystems (2)
lore
Share & tools
lore

Wang Qing

author
#0 lore raw

PATCH 1/1 crypto: Fix return value check in aead_crypt()

Fix passing zero to 'PTR_ERR' warning

---
 drivers/crypto/caam/caamalg_qi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/caam/caamalg_qi.c +1 -1
index 66f60d7..add60e8
@@ -1166,7 +1166,7 @@ static inline int aead_crypt(struct aead_request *req, bool encrypt)
 	/* allocate extended descriptor */
 	edesc = aead_edesc_alloc(req, encrypt);
 	if (IS_ERR_OR_NULL(edesc))
-		return PTR_ERR(edesc);
+		return PTR_ERR_OR_ZERO(edesc);
 
 	/* Create and submit job descriptor */
 	ret = caam_qi_enqueue(ctx->qidev, &edesc->drv_req);
Signature · 1 line
2.7.4
maintainer
#1 lore raw

crypto: caam/qi - simplify error path for context allocation

Quoted 2 lines · Wang Qing

Fix passing zero to 'PTR_ERR' warning

Thanks.

Quoted 10 lines
---
 drivers/crypto/caam/caamalg_qi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/caam/caamalg_qi.c +0 -0
index 66f60d7..add60e8

drivers/crypto/caam/caamalg_qi.c static inline int aead_crypt(struct aead_request *req, bool encrypt) · line 1170

Quoted 6 lines
drivers/crypto/caam/caamalg_qi.c +1 -1
@@ -1166,7 +1166,7 @@ static inline int aead_crypt(struct aead_request *req, bool encrypt)
 	/* allocate extended descriptor */
 	edesc = aead_edesc_alloc(req, encrypt);
 	if (IS_ERR_OR_NULL(edesc))
-		return PTR_ERR(edesc);
+		return PTR_ERR_OR_ZERO(edesc);
 

Digging a bit into the logic, it turns out aead_edesc_alloc() can't return a NULL pointer.

-- >8 --

Subject: [PATCH] crypto: caam/qi - simplify error path for context allocation

Wang Qing reports that IS_ERR_OR_NULL() should be matched with PTR_ERR_OR_ZERO(), not PTR_ERR().

As it turns out, the error path always returns an error code, i.e. NULL is never returned.
Update the code accordingly - s/IS_ERR_OR_NULL/IS_ERR.

---
 drivers/crypto/caam/caamalg_qi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/caam/caamalg_qi.c +4 -4
index a24ae966df4a..189a7438b29c 100644
@@ -852,7 +852,7 @@ static struct caam_drv_ctx *get_drv_ctx(struct caam_ctx *ctx,
 
 			cpu = smp_processor_id();
 			drv_ctx = caam_drv_ctx_init(ctx->qidev, &cpu, desc);
-			if (!IS_ERR_OR_NULL(drv_ctx))
+			if (!IS_ERR(drv_ctx))
 				drv_ctx->op_type = type;
 
 			ctx->drv_ctx[type] = drv_ctx;
@@ -955,7 +955,7 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
 	struct caam_drv_ctx *drv_ctx;
 
 	drv_ctx = get_drv_ctx(ctx, encrypt ? ENCRYPT : DECRYPT);
-	if (IS_ERR_OR_NULL(drv_ctx))
+	if (IS_ERR(drv_ctx))
 		return (struct aead_edesc *)drv_ctx;
 
 	/* allocate space for base edesc and hw desc commands, link tables */
@@ -1165,7 +1165,7 @@ static inline int aead_crypt(struct aead_request *req, bool encrypt)
 
 	/* allocate extended descriptor */
 	edesc = aead_edesc_alloc(req, encrypt);
-	if (IS_ERR_OR_NULL(edesc))
+	if (IS_ERR(edesc))
 		return PTR_ERR(edesc);
 
 	/* Create and submit job descriptor */
@@ -1259,7 +1259,7 @@ static struct skcipher_edesc *skcipher_edesc_alloc(struct skcipher_request *req,
 	struct caam_drv_ctx *drv_ctx;
 
 	drv_ctx = get_drv_ctx(ctx, encrypt ? ENCRYPT : DECRYPT);
-	if (IS_ERR_OR_NULL(drv_ctx))
+	if (IS_ERR(drv_ctx))
 		return (struct skcipher_edesc *)drv_ctx;
 
 	src_nents = sg_nents_for_len(req->src, req->cryptlen);
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: crypto: caam/qi - simplify error path for context allocation

Quoted 4 lines · Horia Geantă

-- >8 --

Subject: [PATCH] crypto: caam/qi - simplify error path for context allocation

You can't do this. Patchwork takes any replies with the same Subject line as a comment.

You need to resend this patch with a different subject.

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
maintainer
#3 lore raw

Re: crypto: caam/qi - simplify error path for context allocation

Quoted 10 lines · Herbert Xu
Quoted 4 lines · Horia Geantă

-- >8 --

Subject: [PATCH] crypto: caam/qi - simplify error path for context allocation

You can't do this. Patchwork takes any replies with the same Subject line as a comment.

You need to resend this patch with a different subject.

Nevermind, you did change the email subject too.

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
maintainer
#4 lore raw

Re: crypto: caam/qi - simplify error path for context allocation

In reply to Horia Geantă
Quoted 8 lines · Horia Geantă

Wang Qing reports that IS_ERR_OR_NULL() should be matched with PTR_ERR_OR_ZERO(), not PTR_ERR().

As it turns out, the error path always returns an error code, i.e. NULL is never returned.
Update the code accordingly - s/IS_ERR_OR_NULL/IS_ERR.

Quoted 5 lines
---
 drivers/crypto/caam/caamalg_qi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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