crypto: mediatek - Fix wrong return value in mtk_desc_ring_alloc()
authorTianjia Zhang <tianjia.zhang@linux.alibaba.com>
Sun, 2 Aug 2020 11:15:32 +0000 (19:15 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Aug 2020 04:45:27 +0000 (14:45 +1000)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/mediatek/mtk-platform.c

index 7e3ad08..ef4339e 100644 (file)
@@ -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 @@ err_cleanup:
                                  ring[i]->cmd_base, ring[i]->cmd_dma);
                kfree(ring[i]);
        }
-       return err;
+       return -ENOMEM;
 }
 
 static int mtk_crypto_probe(struct platform_device *pdev)