opalcore_config_init() gets a reference on the "/ibm,opal/dump" device
node with of_find_node_by_path(), but when the node is not compatible
with "ibm,opal-dump" it warns and returns without dropping that
reference, leaking the node. Every other exit path, including the
adjacent of_get_property() failure, releases it.

Release the device node reference before returning from that error path.

Fixes: 6f713d18144c ("powerpc/opalcore: export /sys/firmware/opal/core for 
analysing opal crashes")
Assisted-by: DeepSeek-V4.1-Flash
Signed-off-by: Haotian Zhang <[email protected]>
---
 arch/powerpc/platforms/powernv/opal-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/platforms/powernv/opal-core.c 
b/arch/powerpc/platforms/powernv/opal-core.c
index 32662d30d70f..fbf4677e811d 100644
--- a/arch/powerpc/platforms/powernv/opal-core.c
+++ b/arch/powerpc/platforms/powernv/opal-core.c
@@ -455,6 +455,7 @@ static void __init opalcore_config_init(void)
 
        if (!of_device_is_compatible(np, "ibm,opal-dump")) {
                pr_warn("Support missing for this f/w version!\n");
+               of_node_put(np);
                return;
        }
 
-- 
2.25.1


Reply via email to