]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: dwc: Perform cleanup in the error path of dw_pcie_resume_noirq()
authorManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Thu, 26 Feb 2026 13:39:51 +0000 (19:09 +0530)
committerManivannan Sadhasivam <mani@kernel.org>
Mon, 9 Mar 2026 06:30:12 +0000 (12:00 +0530)
If the dw_pcie_resume_noirq() API fails, it just returns the errno without
doing cleanup in the error path, leading to resource leak.

So perform cleanup in the error path.

Fixes: 4774faf854f5 ("PCI: dwc: Implement generic suspend/resume functionality")
Reported-by: Senchuan Zhang <zhangsenchuan@eswincomputing.com>
Closes: https://lore.kernel.org/linux-pci/78296255.3869.19c8eb694d6.Coremail.zhangsenchuan@eswincomputing.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20260226133951.296743-1-mani@kernel.org
drivers/pci/controller/dwc/pcie-designware-host.c

index ba183fc3e77cd936a4b691673378fcae47c6f456..a74339982c2464f35b2f063df1ca1086ee721340 100644 (file)
@@ -1304,15 +1304,24 @@ int dw_pcie_resume_noirq(struct dw_pcie *pci)
 
        ret = dw_pcie_start_link(pci);
        if (ret)
-               return ret;
+               goto err_deinit;
 
        ret = dw_pcie_wait_for_link(pci);
-       if (ret)
-               return ret;
+       if (ret == -ETIMEDOUT)
+               goto err_stop_link;
 
        if (pci->pp.ops->post_init)
                pci->pp.ops->post_init(&pci->pp);
 
+       return 0;
+
+err_stop_link:
+       dw_pcie_stop_link(pci);
+
+err_deinit:
+       if (pci->pp.ops->deinit)
+               pci->pp.ops->deinit(&pci->pp);
+
        return ret;
 }
 EXPORT_SYMBOL_GPL(dw_pcie_resume_noirq);