Skip to content

Commit

Permalink
crypto: hisilicon/qm - fix missing destroy qp_idr
Browse files Browse the repository at this point in the history
[ Upstream commit 116be08 ]

In the function hisi_qm_memory_init(), if resource alloc fails after
idr_init, the initialized qp_idr needs to be destroyed.

Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Yang Shen <shenyang39@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Weili Qian authored and gregkh committed Dec 31, 2022
1 parent d567776 commit aaef0bd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/crypto/hisilicon/qm.c
Expand Up @@ -5727,8 +5727,8 @@ static int hisi_qm_memory_init(struct hisi_qm *qm)
GFP_ATOMIC);
dev_dbg(dev, "allocate qm dma buf size=%zx)\n", qm->qdma.size);
if (!qm->qdma.va) {
ret = -ENOMEM;
goto err_alloc_qdma;
ret = -ENOMEM;
goto err_destroy_idr;
}

QM_INIT_BUF(qm, eqe, QM_EQ_DEPTH);
Expand All @@ -5744,7 +5744,8 @@ static int hisi_qm_memory_init(struct hisi_qm *qm)

err_alloc_qp_array:
dma_free_coherent(dev, qm->qdma.size, qm->qdma.va, qm->qdma.dma);
err_alloc_qdma:
err_destroy_idr:
idr_destroy(&qm->qp_idr);
kfree(qm->factor);

return ret;
Expand Down

0 comments on commit aaef0bd

Please sign in to comment.