All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] PCI: tegra: Fix OF node reference leak
@ 2021-05-04 17:17 Christophe JAILLET
  2021-05-04 17:17 ` [PATCH 2/3] PCI: tegra: Use 'seq_puts' instead of 'seq_printf' Christophe JAILLET
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Christophe JAILLET @ 2021-05-04 17:17 UTC (permalink / raw)
  To: thierry.reding, lorenzo.pieralisi, robh, bhelgaas, jonathanh
  Cc: linux-tegra, linux-pci, linux-kernel, kernel-janitors,
	Christophe JAILLET

Commit 9e38e690ace3 ("PCI: tegra: Fix OF node reference leak") has fixed
some node reference leaks in this function but missed some of them.

In fact, having 'port' referenced in the 'rp' structure is not enough to
prevent the leak, until 'rp' is actually added in the 'pcie->ports' list.

Add the missing 'goto err_node_put' accordingly.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/pci/controller/pci-tegra.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
index 8069bd9232d4..006bf0346dec 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -2193,13 +2193,15 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 		rp->np = port;
 
 		rp->base = devm_pci_remap_cfg_resource(dev, &rp->regs);
-		if (IS_ERR(rp->base))
-			return PTR_ERR(rp->base);
+		if (IS_ERR(rp->base)) {
+			err = PTR_ERR(rp->base);
+			goto err_node_put;
+		}
 
 		label = devm_kasprintf(dev, GFP_KERNEL, "pex-reset-%u", index);
 		if (!label) {
-			dev_err(dev, "failed to create reset GPIO label\n");
-			return -ENOMEM;
+			err = -ENOMEM;
+			goto err_node_put;
 		}
 
 		/*
@@ -2217,7 +2219,8 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 			} else {
 				dev_err(dev, "failed to get reset GPIO: %ld\n",
 					PTR_ERR(rp->reset_gpio));
-				return PTR_ERR(rp->reset_gpio);
+				err = PTR_ERR(rp->reset_gpio);
+				goto err_node_put;
 			}
 		}
 
-- 
2.30.2


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

end of thread, other threads:[~2021-08-05 10:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 17:17 [PATCH 1/3] PCI: tegra: Fix OF node reference leak Christophe JAILLET
2021-05-04 17:17 ` [PATCH 2/3] PCI: tegra: Use 'seq_puts' instead of 'seq_printf' Christophe JAILLET
2021-07-05 17:01   ` Vidya Sagar
2021-05-04 17:18 ` [PATCH 3/3] PCI: tegra: make const array err_msg static Christophe JAILLET
2021-07-05 17:01   ` Vidya Sagar
2021-07-05 22:31   ` Krzysztof Wilczyński
2021-07-07 18:24     ` Christophe JAILLET
2021-07-07 19:52       ` Krzysztof Wilczyński
2021-06-22 10:42 ` [PATCH 1/3] PCI: tegra: Fix OF node reference leak Lorenzo Pieralisi
2021-07-05 17:00 ` Vidya Sagar
2021-08-05 10:43 ` Lorenzo Pieralisi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.