diff mbox series

[-next] crypto: starfive - fix return value check in starfive_aes_prepare_req()

Message ID 20230731140249.2691001-1-yangyingliang@huawei.com
State Accepted
Commit 33b53749aa1f9fb0f5aa0ac37269944a080b982f
Headers show
Series [-next] crypto: starfive - fix return value check in starfive_aes_prepare_req() | expand

Commit Message

Yang Yingliang July 31, 2023, 2:02 p.m. UTC
kzalloc() returns NULL pointer not PTR_ERR() when it fails,
so replace the IS_ERR() check with NULL pointer check.

Fixes: e22471c2331c ("crypto: starfive - Add AES skcipher and aead support")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/crypto/starfive/jh7110-aes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Herbert Xu Aug. 11, 2023, 11:28 a.m. UTC | #1
On Mon, Jul 31, 2023 at 10:02:49PM +0800, Yang Yingliang wrote:
> kzalloc() returns NULL pointer not PTR_ERR() when it fails,
> so replace the IS_ERR() check with NULL pointer check.
> 
> Fixes: e22471c2331c ("crypto: starfive - Add AES skcipher and aead support")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/crypto/starfive/jh7110-aes.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/starfive/jh7110-aes.c b/drivers/crypto/starfive/jh7110-aes.c
index 04dd7958054f..278dfa4aa743 100644
--- a/drivers/crypto/starfive/jh7110-aes.c
+++ b/drivers/crypto/starfive/jh7110-aes.c
@@ -496,8 +496,8 @@  static int starfive_aes_prepare_req(struct skcipher_request *req,
 
 	if (cryp->assoclen) {
 		rctx->adata = kzalloc(ALIGN(cryp->assoclen, AES_BLOCK_SIZE), GFP_KERNEL);
-		if (IS_ERR(rctx->adata))
-			return dev_err_probe(cryp->dev, PTR_ERR(rctx->adata),
+		if (!rctx->adata)
+			return dev_err_probe(cryp->dev, -ENOMEM,
 					     "Failed to alloc memory for adata");
 
 		scatterwalk_copychunks(rctx->adata, &cryp->in_walk, cryp->assoclen, 0);