diff mbox series

PCI: qcom: handle pm_runtime_get_sync failure case

Message ID 20200605031643.18171-1-navid.emamdoost@gmail.com (mailing list archive)
State Accepted
Commit cb52a40202420d3886b84ea13dba699c9da13eb0
Headers show
Series PCI: qcom: handle pm_runtime_get_sync failure case | expand

Commit Message

Navid Emamdoost June 5, 2020, 3:16 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/dwc/pcie-qcom.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Lorenzo Pieralisi July 2, 2020, 10:27 a.m. UTC | #1
On Thu, Jun 04, 2020 at 10:16:43PM -0500, 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>
> ---
>  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/

> diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
> index 138e1a2d21cc..48c434e6e915 100644
> --- a/drivers/pci/controller/dwc/pcie-qcom.c
> +++ b/drivers/pci/controller/dwc/pcie-qcom.c
> @@ -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;
> -- 
> 2.17.1
>
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
index 138e1a2d21cc..48c434e6e915 100644
--- a/drivers/pci/controller/dwc/pcie-qcom.c
+++ b/drivers/pci/controller/dwc/pcie-qcom.c
@@ -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;