Commit 3d31adc4 authored by Liang He's avatar Liang He Committed by Michael Ellerman

powerpc/sysdev: Add missing of_node_put()s

Add of_node_put() in various paths to drop references once they are no
longer needed.
Signed-off-by: default avatarLiang He <windhl@126.com>
[mpe: Rewrite change log]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220620130221.4073228-1-windhl@126.com
parent cd772e65
...@@ -181,6 +181,7 @@ static int setup_one_atmu(struct ccsr_pci __iomem *pci, ...@@ -181,6 +181,7 @@ static int setup_one_atmu(struct ccsr_pci __iomem *pci,
static bool is_kdump(void) static bool is_kdump(void)
{ {
struct device_node *node; struct device_node *node;
bool ret;
node = of_find_node_by_type(NULL, "memory"); node = of_find_node_by_type(NULL, "memory");
if (!node) { if (!node) {
...@@ -188,7 +189,10 @@ static bool is_kdump(void) ...@@ -188,7 +189,10 @@ static bool is_kdump(void)
return false; return false;
} }
return of_property_read_bool(node, "linux,usable-memory"); ret = of_property_read_bool(node, "linux,usable-memory");
of_node_put(node);
return ret;
} }
/* atmu setup for fsl pci/pcie controller */ /* atmu setup for fsl pci/pcie controller */
......
...@@ -121,6 +121,7 @@ static unsigned int mpic_msgr_number_of_blocks(void) ...@@ -121,6 +121,7 @@ static unsigned int mpic_msgr_number_of_blocks(void)
count += 1; count += 1;
} }
of_node_put(aliases);
} }
return count; return count;
...@@ -144,12 +145,18 @@ static int mpic_msgr_block_number(struct device_node *node) ...@@ -144,12 +145,18 @@ static int mpic_msgr_block_number(struct device_node *node)
for (index = 0; index < number_of_blocks; ++index) { for (index = 0; index < number_of_blocks; ++index) {
struct property *prop; struct property *prop;
struct device_node *tn;
snprintf(buf, sizeof(buf), "mpic-msgr-block%d", index); snprintf(buf, sizeof(buf), "mpic-msgr-block%d", index);
prop = of_find_property(aliases, buf, NULL); prop = of_find_property(aliases, buf, NULL);
if (node == of_find_node_by_path(prop->value)) tn = of_find_node_by_path(prop->value);
if (node == tn) {
of_node_put(tn);
break; break;
} }
of_node_put(tn);
}
of_node_put(aliases);
return index == number_of_blocks ? -1 : index; return index == number_of_blocks ? -1 : index;
} }
......
...@@ -579,12 +579,12 @@ bool __init xive_native_init(void) ...@@ -579,12 +579,12 @@ bool __init xive_native_init(void)
/* Resource 1 is HV window */ /* Resource 1 is HV window */
if (of_address_to_resource(np, 1, &r)) { if (of_address_to_resource(np, 1, &r)) {
pr_err("Failed to get thread mgmnt area resource\n"); pr_err("Failed to get thread mgmnt area resource\n");
return false; goto err_put;
} }
tima = ioremap(r.start, resource_size(&r)); tima = ioremap(r.start, resource_size(&r));
if (!tima) { if (!tima) {
pr_err("Failed to map thread mgmnt area\n"); pr_err("Failed to map thread mgmnt area\n");
return false; goto err_put;
} }
/* Read number of priorities */ /* Read number of priorities */
...@@ -612,7 +612,7 @@ bool __init xive_native_init(void) ...@@ -612,7 +612,7 @@ bool __init xive_native_init(void)
/* Resource 2 is OS window */ /* Resource 2 is OS window */
if (of_address_to_resource(np, 2, &r)) { if (of_address_to_resource(np, 2, &r)) {
pr_err("Failed to get thread mgmnt area resource\n"); pr_err("Failed to get thread mgmnt area resource\n");
return false; goto err_put;
} }
xive_tima_os = r.start; xive_tima_os = r.start;
...@@ -624,7 +624,7 @@ bool __init xive_native_init(void) ...@@ -624,7 +624,7 @@ bool __init xive_native_init(void)
rc = opal_xive_reset(OPAL_XIVE_MODE_EXPL); rc = opal_xive_reset(OPAL_XIVE_MODE_EXPL);
if (rc) { if (rc) {
pr_err("Switch to exploitation mode failed with error %lld\n", rc); pr_err("Switch to exploitation mode failed with error %lld\n", rc);
return false; goto err_put;
} }
/* Setup some dummy HV pool VPs */ /* Setup some dummy HV pool VPs */
...@@ -634,10 +634,15 @@ bool __init xive_native_init(void) ...@@ -634,10 +634,15 @@ bool __init xive_native_init(void)
if (!xive_core_init(np, &xive_native_ops, tima, TM_QW3_HV_PHYS, if (!xive_core_init(np, &xive_native_ops, tima, TM_QW3_HV_PHYS,
max_prio)) { max_prio)) {
opal_xive_reset(OPAL_XIVE_MODE_EMU); opal_xive_reset(OPAL_XIVE_MODE_EMU);
return false; goto err_put;
} }
of_node_put(np);
pr_info("Using %dkB queues\n", 1 << (xive_queue_shift - 10)); pr_info("Using %dkB queues\n", 1 << (xive_queue_shift - 10));
return true; return true;
err_put:
of_node_put(np);
return false;
} }
static bool xive_native_provision_pages(void) static bool xive_native_provision_pages(void)
......
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