public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
* [PATCH] powerpc/pasemi: Use of_root in pas_pci_init()
@ 2022-09-06  1:03 Michael Ellerman
  2022-09-06  6:17 ` Christophe Leroy
  2022-09-23 11:15 ` Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Ellerman @ 2022-09-06  1:03 UTC (permalink / raw)
  To: linuxppc-dev

Currently in pas_pci_init() a reference to the root node is leaked due
to a missing of_node_put(). Instead just use of_root directly.

Note that converting to of_find_compatible_node(NULL, ...) would
not be entirely equivalent, because that would check the compatible
property of the root node, whereas using of_root skips checking the root
node and start the search at the first child of the root.

Reported-by: Liang He <windhl@126•com>
Signed-off-by: Michael Ellerman <mpe@ellerman•id.au>
---
 arch/powerpc/platforms/pasemi/pci.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/platforms/pasemi/pci.c b/arch/powerpc/platforms/pasemi/pci.c
index 55f0160910bf..f27d31414737 100644
--- a/arch/powerpc/platforms/pasemi/pci.c
+++ b/arch/powerpc/platforms/pasemi/pci.c
@@ -270,18 +270,12 @@ static int __init pas_add_bridge(struct device_node *dev)
 
 void __init pas_pci_init(void)
 {
-	struct device_node *np, *root;
+	struct device_node *np;
 	int res;
 
-	root = of_find_node_by_path("/");
-	if (!root) {
-		pr_crit("pas_pci_init: can't find root of device tree\n");
-		return;
-	}
-
 	pci_set_flags(PCI_SCAN_ALL_PCIE_DEVS);
 
-	np = of_find_compatible_node(root, NULL, "pasemi,rootbus");
+	np = of_find_compatible_node(of_root, NULL, "pasemi,rootbus");
 	if (np) {
 		res = pas_add_bridge(np);
 		of_node_put(np);
-- 
2.37.2


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

end of thread, other threads:[~2022-09-23 11:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-06  1:03 [PATCH] powerpc/pasemi: Use of_root in pas_pci_init() Michael Ellerman
2022-09-06  6:17 ` Christophe Leroy
2022-09-06 11:38   ` Michael Ellerman
2022-09-23 11:15 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox