crypto: hisilicon/hpre - fix resource leak in remove process
authorZhiqi Song <songzhiqi1@huawei.com>
Sat, 24 Sep 2022 07:38:31 +0000 (15:38 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Oct 2022 11:05:23 +0000 (19:05 +0800)
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>
drivers/crypto/hisilicon/hpre/hpre_main.c

index 471e5ca720f5781551cffe39744deb0c800d15ac..baf1faec7046f73916c30ed5632cb817a3f4ae13 100644 (file)
@@ -1437,18 +1437,12 @@ err_with_qm_init:
 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);