diff mbox series

[v2] arm: omap2: pm33xx-core: Fix missing of_node_put() in amx3_idle_init()

Message ID 20220701113455.233531-1-windhl@126.com (mailing list archive)
State New, archived
Headers show
Series [v2] arm: omap2: pm33xx-core: Fix missing of_node_put() in amx3_idle_init() | expand

Commit Message

Liang He July 1, 2022, 11:34 a.m. UTC
To keep refcount balance, we need to call of_node_put() for the
reference 'state_node' returned by of_parse_phandle() in fail
path or when it is not used anymore.

Fixes: 06ee7a950b6a ("ARM: OMAP2+: pm33xx-core: Add cpuidle_ops for am335x/am437x")
Co-authored-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Liang He <windhl@126.com>
---
 changelog:
 
 v2: add Co-authored-by Miaoqian Ling and fix tag
 v1: fix missing of_node_put() bug, but with some error with
'format-patch'

 arch/arm/mach-omap2/pm33xx-core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/arm/mach-omap2/pm33xx-core.c b/arch/arm/mach-omap2/pm33xx-core.c
index bf0d25fd2cea..58b98a17746c 100644
--- a/arch/arm/mach-omap2/pm33xx-core.c
+++ b/arch/arm/mach-omap2/pm33xx-core.c
@@ -393,12 +393,15 @@  static int __init amx3_idle_init(struct device_node *cpu_node, int cpu)
 		if (!state_node)
 			break;
 
-		if (!of_device_is_available(state_node))
+		if (!of_device_is_available(state_node)) {
+			of_node_put(state_node);
 			continue;
+		}
 
 		if (i == CPUIDLE_STATE_MAX) {
 			pr_warn("%s: cpuidle states reached max possible\n",
 				__func__);
+			of_node_put(state_node);
 			break;
 		}
 
@@ -408,6 +411,7 @@  static int __init amx3_idle_init(struct device_node *cpu_node, int cpu)
 			states[state_count].wfi_flags |= WFI_FLAG_WAKE_M3 |
 							 WFI_FLAG_FLUSH_CACHE;
 
+		of_node_put(state_node);
 		state_count++;
 	}