]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
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)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 9 Nov 2020 13:48:36 +0000 (14:48 +0100)
BugLink: https://bugs.launchpad.net/bugs/1902115
[ Upstream commit 8cbde6c6a6d2b1599ff90f932304aab7e32fce89 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Ian May <ian.may@canonical.com>
drivers/crypto/mediatek/mtk-platform.c

index 7e3ad085b5bdd2b9c213789c18fa8df46d7f85ae..ef4339e84d034e604a48f6c1c2ace2e955654595 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)