linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: Fix return value check in aead_crypt()
@ 2020-11-06  9:01 Wang Qing
  2020-11-12  9:21 ` crypto: caam/qi - simplify error path for context allocation Horia Geantă
  0 siblings, 1 reply; 5+ messages in thread
From: Wang Qing @ 2020-11-06  9:01 UTC (permalink / raw)
  To: Horia Geantă,
	Aymen Sghaier, Herbert Xu, David S. Miller, linux-crypto,
	linux-kernel
  Cc: Wang Qing

Fix passing zero to 'PTR_ERR' warning

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 drivers/crypto/caam/caamalg_qi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
index 66f60d7..add60e8
--- a/drivers/crypto/caam/caamalg_qi.c
+++ b/drivers/crypto/caam/caamalg_qi.c
@@ -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);
-- 
2.7.4


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

* crypto: caam/qi - simplify error path for context allocation
  2020-11-06  9:01 [PATCH] crypto: Fix return value check in aead_crypt() Wang Qing
@ 2020-11-12  9:21 ` Horia Geantă
  2020-11-13  3:39   ` Herbert Xu
  2020-11-20  6:56   ` Herbert Xu
  0 siblings, 2 replies; 5+ messages in thread
From: Horia Geantă @ 2020-11-12  9:21 UTC (permalink / raw)
  To: Wang Qing, Aymen Sghaier, Herbert Xu, David S. Miller,
	linux-crypto, linux-kernel

On 11/6/2020 11:01 AM, Wang Qing wrote:
> Fix passing zero to 'PTR_ERR' warning
> 
Thanks.

> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
>  drivers/crypto/caam/caamalg_qi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
> index 66f60d7..add60e8
> --- a/drivers/crypto/caam/caamalg_qi.c
> +++ b/drivers/crypto/caam/caamalg_qi.c
> @@ -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.

Reported-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/caamalg_qi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
index a24ae966df4a..189a7438b29c 100644
--- a/drivers/crypto/caam/caamalg_qi.c
+++ b/drivers/crypto/caam/caamalg_qi.c
@@ -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);
-- 
2.17.1

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

* Re: crypto: caam/qi - simplify error path for context allocation
  2020-11-12  9:21 ` crypto: caam/qi - simplify error path for context allocation Horia Geantă
@ 2020-11-13  3:39   ` Herbert Xu
  2020-11-13  3:41     ` Herbert Xu
  2020-11-20  6:56   ` Herbert Xu
  1 sibling, 1 reply; 5+ messages in thread
From: Herbert Xu @ 2020-11-13  3:39 UTC (permalink / raw)
  To: Horia Geantă
  Cc: wangqing, aymen.sghaier, davem, linux-crypto, linux-kernel

Horia Geantă <horia.geanta@nxp.com> wrote:
>
> -- >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,
-- 
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] 5+ messages in thread

* Re: crypto: caam/qi - simplify error path for context allocation
  2020-11-13  3:39   ` Herbert Xu
@ 2020-11-13  3:41     ` Herbert Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2020-11-13  3:41 UTC (permalink / raw)
  To: Horia Geantă
  Cc: wangqing, aymen.sghaier, davem, linux-crypto, linux-kernel

On Fri, Nov 13, 2020 at 02:39:24PM +1100, Herbert Xu wrote:
> Horia Geantă <horia.geanta@nxp.com> wrote:
> >
> > -- >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,
-- 
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] 5+ messages in thread

* Re: crypto: caam/qi - simplify error path for context allocation
  2020-11-12  9:21 ` crypto: caam/qi - simplify error path for context allocation Horia Geantă
  2020-11-13  3:39   ` Herbert Xu
@ 2020-11-20  6:56   ` Herbert Xu
  1 sibling, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2020-11-20  6:56 UTC (permalink / raw)
  To: Horia Geantă
  Cc: Wang Qing, Aymen Sghaier, David S. Miller, linux-crypto, linux-kernel

On Thu, Nov 12, 2020 at 11:21:46AM +0200, Horia Geantă wrote:
> 
> 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.
> 
> Reported-by: Wang Qing <wangqing@vivo.com>
> Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
> ---
>  drivers/crypto/caam/caamalg_qi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

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

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

end of thread, other threads:[~2020-11-20  6:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06  9:01 [PATCH] crypto: Fix return value check in aead_crypt() Wang Qing
2020-11-12  9:21 ` crypto: caam/qi - simplify error path for context allocation Horia Geantă
2020-11-13  3:39   ` Herbert Xu
2020-11-13  3:41     ` Herbert Xu
2020-11-20  6:56   ` 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).