Skip to content

Commit d36337c

Browse files
windhlmpe
authored andcommitted
powerpc/powermac/feature: Add missing of_node_put()
In probe_one_macio(), call of_node_put() for the refernece 'node' escaped out of the for_each_node_by_name() which has increased its refcount. While the 'node' will finally escaped into a global reference, we should still call of_node_put() in fail path which will stop global reference creation. Signed-off-by: Liang He <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ce63c44 commit d36337c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

arch/powerpc/platforms/powermac/feature.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,31 +2632,31 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
26322632
if (!macio_chips[i].of_node)
26332633
break;
26342634
if (macio_chips[i].of_node == node)
2635-
return;
2635+
goto out_put;
26362636
}
26372637

26382638
if (i >= MAX_MACIO_CHIPS) {
26392639
printk(KERN_ERR "pmac_feature: Please increase MAX_MACIO_CHIPS !\n");
26402640
printk(KERN_ERR "pmac_feature: %pOF skipped\n", node);
2641-
return;
2641+
goto out_put;
26422642
}
26432643
addrp = of_get_pci_address(node, 0, &size, NULL);
26442644
if (addrp == NULL) {
26452645
printk(KERN_ERR "pmac_feature: %pOF: can't find base !\n",
26462646
node);
2647-
return;
2647+
goto out_put;
26482648
}
26492649
addr = of_translate_address(node, addrp);
26502650
if (addr == 0) {
26512651
printk(KERN_ERR "pmac_feature: %pOF, can't translate base !\n",
26522652
node);
2653-
return;
2653+
goto out_put;
26542654
}
26552655
base = ioremap(addr, (unsigned long)size);
26562656
if (!base) {
26572657
printk(KERN_ERR "pmac_feature: %pOF, can't map mac-io chip !\n",
26582658
node);
2659-
return;
2659+
goto out_put;
26602660
}
26612661
if (type == macio_keylargo || type == macio_keylargo2) {
26622662
const u32 *did = of_get_property(node, "device-id", NULL);
@@ -2677,6 +2677,11 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
26772677
macio_chips[i].rev = *revp;
26782678
printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
26792679
macio_names[type], macio_chips[i].rev, macio_chips[i].base);
2680+
2681+
return;
2682+
2683+
out_put:
2684+
of_node_put(node);
26802685
}
26812686

26822687
static int __init

0 commit comments

Comments
 (0)