soc: rockchip: grf: fix device node refcount leak in error path
PATCH 1/1 soc: rockchip: grf: fix device node refcount leak in error path
From: Pei Xiao <[email protected]>
The for_each_matching_node_and_match() macro automatically manages device node reference counts during normal iteration. However, when breaking out of the loop early with return, the current iteration's node is not automatically released, leading to a reference count leak.
Fix this by adding of_node_put() before returning from the loop when fails.
--- drivers/soc/rockchip/grf.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/rockchip/grf.c +1 -0
@@ -231,6 +231,7 @@ static int __init rockchip_grf_init(void) grf =syscon_node_to_regmap (np);if (IS_ERR (grf)) {pr_err ("%s: could not get grf syscon\n" , __func__); +of_node_put (np);return PTR_ERR (grf); }
Signature · 1 line
2.25.1
Heiko Stübner
maintainerHi,
Am Samstag, 21. Februar 2026, 01:40:27 Mitteleuropäische Normalzeit schrieb [email protected]:
Quoted 7 lines
From: Pei Xiao <[email protected]>
The
for_each_matching_node_and_match()macro automatically manages device node reference counts during normal iteration. However, when breaking out of the loop early with return, the current iteration's node is not automatically released, leading to a reference count leak.
Quoted 5 lines
Fix this by adding
of_node_put()before returning from the loop when fails.Fixes 75fb63ae0312 ("soc: rockchip: grf: Support multiple grf to be handled")Signed-off-by Pei Xiao <[email protected]>
Felix Gu was slightly faster [0], so I'll apply their patch once the merge- window is closed.
Thanks
Heiko
Heiko Stübner
maintainerAm Samstag, 21. Februar 2026, 15:51:46 Mitteleuropäische Normalzeit schrieb Heiko Stübner:
Quoted 10 lines
Hi,
Am Samstag, 21. Februar 2026, 01:40:27 Mitteleuropäische Normalzeit schrieb [email protected]:
Quoted 7 lines
From: Pei Xiao <[email protected]>
The
for_each_matching_node_and_match()macro automatically manages device node reference counts during normal iteration. However, when breaking out of the loop early with return, the current iteration's node is not automatically released, leading to a reference count leak.
Quoted 8 lines
Quoted 5 lines
Fix this by adding
of_node_put()before returning from the loop when fails.Fixes 75fb63ae0312 ("soc: rockchip: grf: Support multiple grf to be handled")Signed-off-by Pei Xiao <[email protected]>Felix Gu was slightly faster [0], so I'll apply their patch once the merge- window is closed.
and I just realized that Shawn was actually even earlier [1]
Quoted 6 lines
Thanks
Heiko