[PATCH] arm: mach-rockchip: Add missing of_node_put

heliang windhl at 126.com
Wed Jun 15 00:36:31 PDT 2022


In rockchip_suspend_init, of_find_matching_node_and_match() will return
a node pointer with refcount incremented. We should use of_node_put()
in fail path or when the pointer is not used anymore.

Signed-off-by: heliang <windhl at 126.com>
---
 arch/arm/mach-rockchip/pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/pm.c b/arch/arm/mach-rockchip/pm.c
index 87389d9456b9..5db6a6c6c088 100644
--- a/arch/arm/mach-rockchip/pm.c
+++ b/arch/arm/mach-rockchip/pm.c
@@ -310,6 +310,7 @@ void __init rockchip_suspend_init(void)
 	np = of_find_matching_node_and_match(NULL, rockchip_pmu_of_device_ids,
 					     &match);
 	if (!match) {
+		of_node_put(np);
 		pr_err("Failed to find PMU node\n");
 		return;
 	}
@@ -319,10 +320,11 @@ void __init rockchip_suspend_init(void)
 		ret = pm_data->init(np);
 
 		if (ret) {
+			of_node_put(np);
 			pr_err("%s: matches init error %d\n", __func__, ret);
 			return;
 		}
 	}
-
+	of_node_put(np);
 	suspend_set_ops(pm_data->ops);
 }
-- 
2.25.1




More information about the linux-arm-kernel mailing list