2016-12-01 20:50:04

by Dan Carpenter

[permalink] [raw]
Subject: [patch] crypto: chcr - checking for IS_ERR() instead of NULL

The create_hash_wr() function never returns error pointers. It returns
NULL on error.

Fixes: 358961d1cd1e ("crypto: chcr - Added new structure chcr_wr")
Signed-off-by: Dan Carpenter <[email protected]>

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index 32361dd..2ed1e24 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -958,9 +958,8 @@ static int chcr_ahash_update(struct ahash_request *req)
req_ctx->result = 0;
req_ctx->data_len += params.sg_len + params.bfr_len;
skb = create_hash_wr(req, &params);
-
- if (IS_ERR(skb))
- return PTR_ERR(skb);
+ if (!skb)
+ return -ENOMEM;

if (remainder) {
u8 *temp;
@@ -1023,8 +1022,8 @@ static int chcr_ahash_final(struct ahash_request *req)
params.more = 0;
}
skb = create_hash_wr(req, &params);
- if (IS_ERR(skb))
- return PTR_ERR(skb);
+ if (!skb)
+ return -ENOMEM;

skb->dev = u_ctx->lldi.ports[0];
set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);
@@ -1074,8 +1073,8 @@ static int chcr_ahash_finup(struct ahash_request *req)
}

skb = create_hash_wr(req, &params);
- if (IS_ERR(skb))
- return PTR_ERR(skb);
+ if (!skb)
+ return -ENOMEM;

skb->dev = u_ctx->lldi.ports[0];
set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);
@@ -1125,8 +1124,8 @@ static int chcr_ahash_digest(struct ahash_request *req)
}

skb = create_hash_wr(req, &params);
- if (IS_ERR(skb))
- return PTR_ERR(skb);
+ if (!skb)
+ return -ENOMEM;

skb->dev = u_ctx->lldi.ports[0];
set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);


2016-12-02 06:12:42

by Harsh Jain

[permalink] [raw]
Subject: Re: [patch] crypto: chcr - checking for IS_ERR() instead of NULL



On 02-12-2016 11:29, Harsh Jain wrote:
>
> On 02-12-2016 02:19, Dan Carpenter wrote:
>> The create_hash_wr() function never returns error pointers. It returns
>> NULL on error.
> Will fix the same, Thanks
It's a patch mail not bug reporting! Sorry for confusion. You have already fixed it. Thanks.
>> Fixes: 358961d1cd1e ("crypto: chcr - Added new structure chcr_wr")
>> Signed-off-by: Dan Carpenter <[email protected]>
>>
>> diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
>> index 32361dd..2ed1e24 100644
>> --- a/drivers/crypto/chelsio/chcr_algo.c
>> +++ b/drivers/crypto/chelsio/chcr_algo.c
>> @@ -958,9 +958,8 @@ static int chcr_ahash_update(struct ahash_request *req)
>> req_ctx->result = 0;
>> req_ctx->data_len += params.sg_len + params.bfr_len;
>> skb = create_hash_wr(req, &params);
>> -
>> - if (IS_ERR(skb))
>> - return PTR_ERR(skb);
>> + if (!skb)
>> + return -ENOMEM;
>>
>> if (remainder) {
>> u8 *temp;
>> @@ -1023,8 +1022,8 @@ static int chcr_ahash_final(struct ahash_request *req)
>> params.more = 0;
>> }
>> skb = create_hash_wr(req, &params);
>> - if (IS_ERR(skb))
>> - return PTR_ERR(skb);
>> + if (!skb)
>> + return -ENOMEM;
>>
>> skb->dev = u_ctx->lldi.ports[0];
>> set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);
>> @@ -1074,8 +1073,8 @@ static int chcr_ahash_finup(struct ahash_request *req)
>> }
>>
>> skb = create_hash_wr(req, &params);
>> - if (IS_ERR(skb))
>> - return PTR_ERR(skb);
>> + if (!skb)
>> + return -ENOMEM;
>>
>> skb->dev = u_ctx->lldi.ports[0];
>> set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);
>> @@ -1125,8 +1124,8 @@ static int chcr_ahash_digest(struct ahash_request *req)
>> }
>>
>> skb = create_hash_wr(req, &params);
>> - if (IS_ERR(skb))
>> - return PTR_ERR(skb);
>> + if (!skb)
>> + return -ENOMEM;
>>
>> skb->dev = u_ctx->lldi.ports[0];
>> set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);

2016-12-02 06:54:09

by Harsh Jain

[permalink] [raw]
Subject: Re: [patch] crypto: chcr - checking for IS_ERR() instead of NULL



On 02-12-2016 02:19, Dan Carpenter wrote:
> The create_hash_wr() function never returns error pointers. It returns
> NULL on error.
Will fix the same, Thanks
>
> Fixes: 358961d1cd1e ("crypto: chcr - Added new structure chcr_wr")
> Signed-off-by: Dan Carpenter <[email protected]>
>
> diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
> index 32361dd..2ed1e24 100644
> --- a/drivers/crypto/chelsio/chcr_algo.c
> +++ b/drivers/crypto/chelsio/chcr_algo.c
> @@ -958,9 +958,8 @@ static int chcr_ahash_update(struct ahash_request *req)
> req_ctx->result = 0;
> req_ctx->data_len += params.sg_len + params.bfr_len;
> skb = create_hash_wr(req, &params);
> -
> - if (IS_ERR(skb))
> - return PTR_ERR(skb);
> + if (!skb)
> + return -ENOMEM;
>
> if (remainder) {
> u8 *temp;
> @@ -1023,8 +1022,8 @@ static int chcr_ahash_final(struct ahash_request *req)
> params.more = 0;
> }
> skb = create_hash_wr(req, &params);
> - if (IS_ERR(skb))
> - return PTR_ERR(skb);
> + if (!skb)
> + return -ENOMEM;
>
> skb->dev = u_ctx->lldi.ports[0];
> set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);
> @@ -1074,8 +1073,8 @@ static int chcr_ahash_finup(struct ahash_request *req)
> }
>
> skb = create_hash_wr(req, &params);
> - if (IS_ERR(skb))
> - return PTR_ERR(skb);
> + if (!skb)
> + return -ENOMEM;
>
> skb->dev = u_ctx->lldi.ports[0];
> set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);
> @@ -1125,8 +1124,8 @@ static int chcr_ahash_digest(struct ahash_request *req)
> }
>
> skb = create_hash_wr(req, &params);
> - if (IS_ERR(skb))
> - return PTR_ERR(skb);
> + if (!skb)
> + return -ENOMEM;
>
> skb->dev = u_ctx->lldi.ports[0];
> set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_channel_id);

2016-12-07 12:07:29

by Herbert Xu

[permalink] [raw]
Subject: Re: [patch] crypto: chcr - checking for IS_ERR() instead of NULL

On Thu, Dec 01, 2016 at 11:49:37PM +0300, Dan Carpenter wrote:
> The create_hash_wr() function never returns error pointers. It returns
> NULL on error.
>
> Fixes: 358961d1cd1e ("crypto: chcr - Added new structure chcr_wr")
> Signed-off-by: Dan Carpenter <[email protected]>

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt