2022-12-18 14:28:21

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH] ARM: hisi: add missing of_node_put calls

A node that is returned by of_find_compatible_node has its refcount
incremented. We have to call of_node_put when the node is no longer
needed.

For hip04_smp_init, the easiest option is to call of_node_put for all
nodes at the end of the function. If we jump to the end of the function
because of an error, unused local np... pointers are NULL by default
and of_node_put(NULL) just returns.

Signed-off-by: Martin Kaiser <[email protected]>
---
compile-tested only, I don't have this hardware

arch/arm/mach-hisi/platmcpm.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-hisi/platmcpm.c b/arch/arm/mach-hisi/platmcpm.c
index 258586e31333..e4be6da07242 100644
--- a/arch/arm/mach-hisi/platmcpm.c
+++ b/arch/arm/mach-hisi/platmcpm.c
@@ -341,6 +341,9 @@ static int __init hip04_smp_init(void)
err_reloc:
memblock_phys_free(hip04_boot_method[0], hip04_boot_method[1]);
err:
+ of_node_put(np);
+ of_node_put(np_sctl);
+ of_node_put(np_fab);
return ret;
}
early_initcall(hip04_smp_init);
--
2.30.2