diff mbox series

crypto: hisilicon/hpre - fix resource leak in remove process

Message ID 20220924073831.38479-1-songzhiqi1@huawei.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: hisilicon/hpre - fix resource leak in remove process | expand

Commit Message

Zhiqi Song Sept. 24, 2022, 7:38 a.m. UTC
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>
---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Herbert Xu Oct. 21, 2022, 11:32 a.m. UTC | #1
On Sat, Sep 24, 2022 at 03:38:31PM +0800, Zhiqi Song wrote:
> 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>
> ---
>  drivers/crypto/hisilicon/hpre/hpre_main.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c
index 471e5ca720f5..baf1faec7046 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -1437,18 +1437,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);