diff mbox series

crypto: mediatek - Fix wrong return value in mtk_desc_ring_alloc()

Message ID 20200802111532.5110-1-tianjia.zhang@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series crypto: mediatek - Fix wrong return value in mtk_desc_ring_alloc() | expand

Commit Message

tianjia.zhang Aug. 2, 2020, 11:15 a.m. UTC
In case of memory allocation failure, a negative error code should
be returned.

Fixes: 785e5c616c849 ("crypto: mediatek - Add crypto driver support for some MediaTek chips")
Cc: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 drivers/crypto/mediatek/mtk-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Herbert Xu Aug. 21, 2020, 7:55 a.m. UTC | #1
On Sun, Aug 02, 2020 at 07:15:32PM +0800, Tianjia Zhang wrote:
> In case of memory allocation failure, a negative error code should
> be returned.
> 
> Fixes: 785e5c616c849 ("crypto: mediatek - Add crypto driver support for some MediaTek chips")
> Cc: Ryder Lee <ryder.lee@mediatek.com>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  drivers/crypto/mediatek/mtk-platform.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/mediatek/mtk-platform.c b/drivers/crypto/mediatek/mtk-platform.c
index 7e3ad085b5bd..ef4339e84d03 100644
--- a/drivers/crypto/mediatek/mtk-platform.c
+++ b/drivers/crypto/mediatek/mtk-platform.c
@@ -442,7 +442,7 @@  static void mtk_desc_dma_free(struct mtk_cryp *cryp)
 static int mtk_desc_ring_alloc(struct mtk_cryp *cryp)
 {
 	struct mtk_ring **ring = cryp->ring;
-	int i, err = ENOMEM;
+	int i;
 
 	for (i = 0; i < MTK_RING_MAX; i++) {
 		ring[i] = kzalloc(sizeof(**ring), GFP_KERNEL);
@@ -476,7 +476,7 @@  static int mtk_desc_ring_alloc(struct mtk_cryp *cryp)
 				  ring[i]->cmd_base, ring[i]->cmd_dma);
 		kfree(ring[i]);
 	}
-	return err;
+	return -ENOMEM;
 }
 
 static int mtk_crypto_probe(struct platform_device *pdev)