[PATCH] arm: mach-mvebu: Fix refcount leak bug in pm.c

From: Liang He
Date: Fri Jun 17 2022 - 22:15:46 EST


In mvebu_internal_reg_base(), of_find_node_by_name() will return a
node pointer with refcount incremented. We should use of_node_put()
when it is not used anymore.

Signed-off-by: Liang He <windhl@xxxxxxx>
---
arch/arm/mach-mvebu/pm.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-mvebu/pm.c b/arch/arm/mach-mvebu/pm.c
index c487be61d6d8..d00e43241dfa 100644
--- a/arch/arm/mach-mvebu/pm.c
+++ b/arch/arm/mach-mvebu/pm.c
@@ -91,6 +91,7 @@ static phys_addr_t mvebu_internal_reg_base(void)
{
struct device_node *np;
__be32 in_addr[2];
+ phys_addr_t addr;

np = of_find_node_by_name(NULL, "internal-regs");
BUG_ON(!np);
@@ -103,7 +104,11 @@ static phys_addr_t mvebu_internal_reg_base(void)
in_addr[0] = cpu_to_be32(0xf0010000);
in_addr[1] = 0x0;

- return of_translate_address(np, in_addr);
+ addr = of_translate_address(np, in_addr);
+
+ of_node_put(np);
+
+ return addr;
}

static void mvebu_pm_store_armadaxp_bootinfo(u32 *store_addr)
--
2.25.1