Commit d36337ce authored by Liang He's avatar Liang He Committed by Michael Ellerman

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: default avatarLiang He <windhl@126.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220716065412.539153-1-windhl@126.com
parent ce63c44b
...@@ -2632,31 +2632,31 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ ...@@ -2632,31 +2632,31 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
if (!macio_chips[i].of_node) if (!macio_chips[i].of_node)
break; break;
if (macio_chips[i].of_node == node) if (macio_chips[i].of_node == node)
return; goto out_put;
} }
if (i >= MAX_MACIO_CHIPS) { if (i >= MAX_MACIO_CHIPS) {
printk(KERN_ERR "pmac_feature: Please increase MAX_MACIO_CHIPS !\n"); printk(KERN_ERR "pmac_feature: Please increase MAX_MACIO_CHIPS !\n");
printk(KERN_ERR "pmac_feature: %pOF skipped\n", node); printk(KERN_ERR "pmac_feature: %pOF skipped\n", node);
return; goto out_put;
} }
addrp = of_get_pci_address(node, 0, &size, NULL); addrp = of_get_pci_address(node, 0, &size, NULL);
if (addrp == NULL) { if (addrp == NULL) {
printk(KERN_ERR "pmac_feature: %pOF: can't find base !\n", printk(KERN_ERR "pmac_feature: %pOF: can't find base !\n",
node); node);
return; goto out_put;
} }
addr = of_translate_address(node, addrp); addr = of_translate_address(node, addrp);
if (addr == 0) { if (addr == 0) {
printk(KERN_ERR "pmac_feature: %pOF, can't translate base !\n", printk(KERN_ERR "pmac_feature: %pOF, can't translate base !\n",
node); node);
return; goto out_put;
} }
base = ioremap(addr, (unsigned long)size); base = ioremap(addr, (unsigned long)size);
if (!base) { if (!base) {
printk(KERN_ERR "pmac_feature: %pOF, can't map mac-io chip !\n", printk(KERN_ERR "pmac_feature: %pOF, can't map mac-io chip !\n",
node); node);
return; goto out_put;
} }
if (type == macio_keylargo || type == macio_keylargo2) { if (type == macio_keylargo || type == macio_keylargo2) {
const u32 *did = of_get_property(node, "device-id", NULL); 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 ...@@ -2677,6 +2677,11 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
macio_chips[i].rev = *revp; macio_chips[i].rev = *revp;
printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n", printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
macio_names[type], macio_chips[i].rev, macio_chips[i].base); macio_names[type], macio_chips[i].rev, macio_chips[i].base);
return;
out_put:
of_node_put(node);
} }
static int __init static int __init
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment