diff mbox series

PCI: rcar: handle the failure case of pm_runtime_get_sync

Message ID 20200605032315.39071-1-navid.emamdoost@gmail.com
State New
Headers show
Series PCI: rcar: handle the failure case of pm_runtime_get_sync | expand

Commit Message

Navid Emamdoost June 5, 2020, 3:23 a.m. UTC
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.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/pci/controller/pcie-rcar.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Marek Vasut June 6, 2020, 12:17 p.m. UTC | #1
On 6/5/20 5:23 AM, Navid Emamdoost wrote:
> 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.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

This looks like a V2 of
[PATCH] PCI: rcar: fix runtime pm imbalance on error

This looks good to me, but I'm no runtime-pm expert.
diff mbox series

Patch

diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
index 759c6542c5c8..6b4181c0710e 100644
--- a/drivers/pci/controller/pcie-rcar.c
+++ b/drivers/pci/controller/pcie-rcar.c
@@ -1137,7 +1137,7 @@  static int rcar_pcie_probe(struct platform_device *pdev)
 	err = pm_runtime_get_sync(pcie->dev);
 	if (err < 0) {
 		dev_err(pcie->dev, "pm_runtime_get_sync failed\n");
-		goto err_pm_disable;
+		goto err_pm_put;
 	}
 
 	err = rcar_pcie_get_resources(pcie);
@@ -1208,8 +1208,6 @@  static int rcar_pcie_probe(struct platform_device *pdev)
 
 err_pm_put:
 	pm_runtime_put(dev);
-
-err_pm_disable:
 	pm_runtime_disable(dev);
 	pci_free_resource_list(&pcie->resources);