Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pasemi: Use of_root in pas_pci_init()

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>
Link: https://lore.kernel.org/r/20220906010313.1296714-1-mpe@ellerman.id.au

+2 -8
+2 -8
arch/powerpc/platforms/pasemi/pci.c
··· 270 270 271 271 void __init pas_pci_init(void) 272 272 { 273 - struct device_node *np, *root; 273 + struct device_node *np; 274 274 int res; 275 - 276 - root = of_find_node_by_path("/"); 277 - if (!root) { 278 - pr_crit("pas_pci_init: can't find root of device tree\n"); 279 - return; 280 - } 281 275 282 276 pci_set_flags(PCI_SCAN_ALL_PCIE_DEVS); 283 277 284 - np = of_find_compatible_node(root, NULL, "pasemi,rootbus"); 278 + np = of_find_compatible_node(of_root, NULL, "pasemi,rootbus"); 285 279 if (np) { 286 280 res = pas_add_bridge(np); 287 281 of_node_put(np);