usb: cdns3: adjust the partial logic of cdnsp_pci_remove
authorDongliang Mu <dzm91@hust.edu.cn>
Sun, 9 Oct 2022 07:23:05 +0000 (15:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Oct 2022 11:21:40 +0000 (13:21 +0200)
In cdnsp_pci_remove, if pci_is_enabled returns true, it will
call cdns_remove; else it will call kfree. Then both control flow
goes to pci_dev_put.

Adjust this logic by modifying it to an if else.

Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
Acked-by: Pawel Laszczak <pawell@cadence.com>
Link: https://lore.kernel.org/r/20221009072305.1593707-1-dzm91@hust.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/cdns3/cdnsp-pci.c

index fe8a114..efd54ed 100644 (file)
@@ -192,14 +192,12 @@ static void cdnsp_pci_remove(struct pci_dev *pdev)
        if (pci_dev_run_wake(pdev))
                pm_runtime_get_noresume(&pdev->dev);
 
-       if (!pci_is_enabled(func)) {
+       if (pci_is_enabled(func)) {
+               cdns_remove(cdnsp);
+       } else {
                kfree(cdnsp);
-               goto pci_put;
        }
 
-       cdns_remove(cdnsp);
-
-pci_put:
        pci_dev_put(func);
 }