Skip to contentSkip to conversation

PCI: qcom: handle pm_runtime_get_sync failure case

PATCH In review Navid Emamdoost 2 participants 2 messages Jun 5, 2020 – Jul 2, 2020

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

PATCH 1/1 PCI: qcom: handle pm_runtime_get_sync failure case

Calling pm_runtime_get_sync increments the counter even in case of failure, causing incorrect ref count. Call pm_runtime_put if pm_runtime_get_sync fails.

---
 drivers/pci/controller/dwc/pcie-qcom.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +2 -4
index 138e1a2d21cc..48c434e6e915 100644
@@ -1339,10 +1339,8 @@ static int qcom_pcie_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
-	if (ret < 0) {
-		pm_runtime_disable(dev);
-		return ret;
-	}
+	if (ret < 0)
+		goto err_pm_runtime_put;
 
 	pci->dev = dev;
 	pci->ops = &dw_pcie_ops;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 8 lines · Navid Emamdoost

Calling pm_runtime_get_sync increments the counter even in case of failure, causing incorrect ref count. Call pm_runtime_put if pm_runtime_get_sync fails.

---
 drivers/pci/controller/dwc/pcie-qcom.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Navid, I will review and merge Dinghao's version of these patches[1] since he posted them first, I will drop yours from the PCI patch queue, thanks anyway for posting them.

Lorenzo

[1] https://patchwork.kernel.org/patch/11559819/

Quoted 20 lines
drivers/pci/controller/dwc/pcie-qcom.c +2 -4
index 138e1a2d21cc..48c434e6e915 100644
@@ -1339,10 +1339,8 @@ static int qcom_pcie_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
-	if (ret < 0) {
-		pm_runtime_disable(dev);
-		return ret;
-	}
+	if (ret < 0)
+		goto err_pm_runtime_put;
 
 	pci->dev = dev;
 	pci->ops = &dw_pcie_ops;
Signature · 1 line
2.17.1