Skip to contentSkip to conversation

PCI: dwc: Perform cleanup in the error path of dw_pcie_resume_noirq()

PATCH Applied Manivannan Sadhasivam 1 participant 2 messages Feb 26 – Mar 5

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: dwc: Perform cleanup in the error path of dw_pcie_resume_noirq()

From: Manivannan Sadhasivam <[email protected]>

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.

---
 drivers/pci/controller/dwc/pcie-designware-host.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +12 -3
index ba183fc3e77c..a74339982c24 100644
@@ -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);
Signature · 1 line
2.51.0
author Applied
#1 lore raw
Quoted 6 lines · Manivannan Sadhasivam

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.

Applied, thanks!

[1/1] PCI: dwc: Perform cleanup in the error path of dw_pcie_resume_noirq()

      commit: cb5b15bf7a40d76b710fc5367d27f6897ecaa552

Best regards,

Signature · 1 line
Manivannan Sadhasivam <[email protected]>