Skip to content

Commit

Permalink
crypto: mediatek - Fix wrong return value in mtk_desc_ring_alloc()
Browse files Browse the repository at this point in the history
[ Upstream commit 8cbde6c ]

In case of memory allocation failure, a negative error code should
be returned.

Fixes: 785e5c6 ("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>
  • Loading branch information
uudiin authored and gregkh committed Oct 29, 2020
1 parent 36c93e6 commit df29e44
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/mediatek/mtk-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit df29e44

Please sign in to comment.