Skip to contentSkip to conversation

arm: mach-rockchip: (pm) Add missing of_node_put()

PATCH Applied Liang He 3 participants 5 messages Jun 16, 2022 – Jun 22, 2022

Subsystems (3)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH v2 1/1 arm: mach-rockchip: (pm) Add missing of_node_put()

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 it is not used anymore.

---
changelog:

v2: (1) use real name for Sob (2) use goto-label patch style
v1: add of_node_put() for each return

 arch/arm/mach-rockchip/pm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/pm.c +6 -2
index 87389d9456b9..bb46ac4f65d4 100644
@@ -311,7 +311,7 @@ void __init rockchip_suspend_init(void)
 					     &match);
 	if (!match) {
 		pr_err("Failed to find PMU node\n");
-		return;
+		goto out_put;
 	}
 	pm_data = (struct rockchip_pm_data *) match->data;
 
@@ -320,9 +320,13 @@ void __init rockchip_suspend_init(void)
 
 		if (ret) {
 			pr_err("%s: matches init error %d\n", __func__, ret);
-			return;
+			goto out_put;
 		}
 	}
 
 	suspend_set_ops(pm_data->ops);
+	
+out_put:
+	of_node_put(np);
+	
 }
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 3 lines · Liang He

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 it is not used anymore.

Applied, thanks!

[1/1] arm: mach-rockchip: (pm) Add missing of_node_put()

      commit f4470dbfb5ff92804650bc71d115c3f150d430f6

There was an unneeded tab in the blank line above out_put and a completely unneeded blank line added at the end of the function. I dropped both.

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>
author
#2 lore raw
Quoted 5 lines · Heiko Stuebner
Quoted 3 lines · Liang He

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 it is not used anymore.

Quoted 8 lines

Applied, thanks!

[1/1] arm: mach-rockchip: (pm) Add missing of_node_put()

     commit f4470dbfb5ff92804650bc71d115c3f150d430f6

There was an unneeded tab in the blank line above out_put and a completely unneeded blank line added at the end of the function. I dropped both.

Thanks very much for your effort.

I am learning the coding style for kernel code.

Quoted 4 lines

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>
#3 lore raw
In reply to Liang He
Quoted 11 lines · Liang He

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 it is not used anymore.

---
changelog:

v2: (1) use real name for Sob (2) use goto-label patch style
v1: add of_node_put() for each return

Before applying the patch please check it carefully. Previous evidence [1][2] suggests that not it was not even compiled.

[1] https://lore.kernel.org/all/[email protected]/

[2]
https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof

maintainer
#4 lore raw

Am Mittwoch, 22. Juni 2022, 11:00:11 CEST schrieb Krzysztof Kozlowski:

Quoted 9 lines · Liang He
Quoted 8 lines

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 it is not used anymore.

---
changelog:

Quoted 6 lines
Quoted 3 lines

v2: (1) use real name for Sob (2) use goto-label patch style
v1: add of_node_put() for each return

Before applying the patch please check it carefully. Previous evidence [1][2] suggests that not it was not even compiled.

thanks noticing possible issues and for the heads up :-) .

I re-examined the patch and at least in this case the of_node_put addition looks correct - the original code was missing this and not putting the node it got in the error case. And the change also compiles :-) .

Heiko

Quoted 9 lines

[1] https://lore.kernel.org/all/[email protected]/

[2]
https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof