Skip to content

Commit

Permalink
crypto: hisilicon/hpre - fix resource leak in remove process
Browse files Browse the repository at this point in the history
[ Upstream commit 45e6319 ]

In hpre_remove(), when the disable operation of qm sriov failed,
the following logic should continue to be executed to release the
remaining resources that have been allocated, instead of returning
directly, otherwise there will be resource leakage.

Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Zhiqi Song authored and gregkh committed Dec 31, 2022
1 parent adf6a00 commit 2b3e3ec
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/crypto/hisilicon/hpre/hpre_main.c
Expand Up @@ -1143,18 +1143,12 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id)
static void hpre_remove(struct pci_dev *pdev)
{
struct hisi_qm *qm = pci_get_drvdata(pdev);
int ret;

hisi_qm_pm_uninit(qm);
hisi_qm_wait_task_finish(qm, &hpre_devices);
hisi_qm_alg_unregister(qm, &hpre_devices);
if (qm->fun_type == QM_HW_PF && qm->vfs_num) {
ret = hisi_qm_sriov_disable(pdev, true);
if (ret) {
pci_err(pdev, "Disable SRIOV fail!\n");
return;
}
}
if (qm->fun_type == QM_HW_PF && qm->vfs_num)
hisi_qm_sriov_disable(pdev, true);

hpre_debugfs_exit(qm);
hisi_qm_stop(qm, QM_NORMAL);
Expand Down

0 comments on commit 2b3e3ec

Please sign in to comment.