2019-10-19 09:52:56

by tiantao (H)

[permalink] [raw]
Subject: [PATCH] crypto: fix safexcel_hash warning PTR_ERR_OR_ZERO can be used

fix below warning reported by coccicheck.
the below code is only in the crypto-dev tree currently.
drivers/crypto/inside-secure/safexcel_cipher.c:2527:1-3: WARNING:
PTR_ERR_OR_ZERO can be used.

Fixes: 38f21b4bab11 ("crypto: inside-secure - Added support for the AES XCBC ahash")

Signed-off-by: Tian Tao <[email protected]>
---
drivers/crypto/inside-secure/safexcel_hash.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
index 85c3a07..3c71151 100644
--- a/drivers/crypto/inside-secure/safexcel_hash.c
+++ b/drivers/crypto/inside-secure/safexcel_hash.c
@@ -2109,10 +2109,8 @@ static int safexcel_xcbcmac_cra_init(struct crypto_tfm *tfm)

safexcel_ahash_cra_init(tfm);
ctx->kaes = crypto_alloc_cipher("aes", 0, 0);
- if (IS_ERR(ctx->kaes))
- return PTR_ERR(ctx->kaes);

- return 0;
+ return PTR_ERR_OR_ZERO(ctx->kaes);
}

static void safexcel_xcbcmac_cra_exit(struct crypto_tfm *tfm)
--
2.7.4


2019-10-21 08:31:22

by Pascal Van Leeuwen

[permalink] [raw]
Subject: RE: [PATCH] crypto: fix safexcel_hash warning PTR_ERR_OR_ZERO can be used

> -----Original Message-----
> From: [email protected] <[email protected]> On Behalf Of
> Tian Tao
> Sent: Saturday, October 19, 2019 2:45 AM
> To: [email protected]; [email protected]; [email protected]; linux-
> [email protected]
> Cc: [email protected]
> Subject: [PATCH] crypto: fix safexcel_hash warning PTR_ERR_OR_ZERO can be used
>
> fix below warning reported by coccicheck.
> the below code is only in the crypto-dev tree currently.
> drivers/crypto/inside-secure/safexcel_cipher.c:2527:1-3: WARNING:
> PTR_ERR_OR_ZERO can be used.
>
> Fixes: 38f21b4bab11 ("crypto: inside-secure - Added support for the AES XCBC ahash")
>
> Signed-off-by: Tian Tao <[email protected]>
> ---
> drivers/crypto/inside-secure/safexcel_hash.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-
> secure/safexcel_hash.c
> index 85c3a07..3c71151 100644
> --- a/drivers/crypto/inside-secure/safexcel_hash.c
> +++ b/drivers/crypto/inside-secure/safexcel_hash.c
> @@ -2109,10 +2109,8 @@ static int safexcel_xcbcmac_cra_init(struct crypto_tfm *tfm)
>
> safexcel_ahash_cra_init(tfm);
> ctx->kaes = crypto_alloc_cipher("aes", 0, 0);
> - if (IS_ERR(ctx->kaes))
> - return PTR_ERR(ctx->kaes);
>
> - return 0;
> + return PTR_ERR_OR_ZERO(ctx->kaes);
> }
Thanks for spotting, but a similar patch has already been applied.
So this patch is obsolete now.

>
> static void safexcel_xcbcmac_cra_exit(struct crypto_tfm *tfm)
> --
> 2.7.4


Regards,
Pascal van Leeuwen
Silicon IP Architect, Multi-Protocol Engines @ Verimatrix
http://www.insidesecure.com