linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: tegra: handle failure case of pm_runtime_get_sync
@ 2020-06-05  3:12 Navid Emamdoost
  2020-06-05  5:58 ` Jon Hunter
  0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2020-06-05  3:12 UTC (permalink / raw)
  To: Thierry Reding, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas,
	Jonathan Hunter, linux-tegra, linux-pci, linux-kernel
  Cc: emamd001, wu000273, kjlu, smccaman, 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.

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

diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
index 3e64ba6a36a8..3d4b448fd8df 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -2712,6 +2712,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 	err = pm_runtime_get_sync(pcie->dev);
 	if (err < 0) {
 		dev_err(dev, "fail to enable pcie controller: %d\n", err);
+		pm_runtime_put_sync(pcie->dev);
 		goto teardown_msi;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PCI: tegra: handle failure case of pm_runtime_get_sync
  2020-06-05  3:12 [PATCH] PCI: tegra: handle failure case of pm_runtime_get_sync Navid Emamdoost
@ 2020-06-05  5:58 ` Jon Hunter
  0 siblings, 0 replies; 2+ messages in thread
From: Jon Hunter @ 2020-06-05  5:58 UTC (permalink / raw)
  To: Navid Emamdoost, Thierry Reding, Lorenzo Pieralisi, Rob Herring,
	Bjorn Helgaas, linux-tegra, linux-pci, linux-kernel
  Cc: emamd001, wu000273, kjlu, smccaman


On 05/06/2020 04:12, 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/pci-tegra.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
> index 3e64ba6a36a8..3d4b448fd8df 100644
> --- a/drivers/pci/controller/pci-tegra.c
> +++ b/drivers/pci/controller/pci-tegra.c
> @@ -2712,6 +2712,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
>  	err = pm_runtime_get_sync(pcie->dev);
>  	if (err < 0) {
>  		dev_err(dev, "fail to enable pcie controller: %d\n", err);
> +		pm_runtime_put_sync(pcie->dev);
>  		goto teardown_msi;
>  	}

Same thing for this patch, there is already a put in the error path and
so it is not necessary to add the put call here. Just update the goto
label.

Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-05  5:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05  3:12 [PATCH] PCI: tegra: handle failure case of pm_runtime_get_sync Navid Emamdoost
2020-06-05  5:58 ` Jon Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).