arch/arm/mach-rockchip/pm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
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.
Signed-off-by: Liang He <windhl@126.com>
---
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(-)
diff --git a/arch/arm/mach-rockchip/pm.c b/arch/arm/mach-rockchip/pm.c
index 87389d9456b9..bb46ac4f65d4 100644
--- a/arch/arm/mach-rockchip/pm.c
+++ b/arch/arm/mach-rockchip/pm.c
@@ -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);
+
}
--
2.25.1
On 16/06/2022 04:17, Liang He wrote: > 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. > > Signed-off-by: Liang He <windhl@126.com> > --- > 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/202206221602.odN70SHs-lkp@intel.com/ [2] https://lore.kernel.org/all/16f9a971.44e5.1817068ee3c.Coremail.windhl@126.com/ Best regards, Krzysztof
Am Mittwoch, 22. Juni 2022, 11:00:11 CEST schrieb Krzysztof Kozlowski: > On 16/06/2022 04:17, Liang He wrote: > > 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. > > > > Signed-off-by: Liang He <windhl@126.com> > > --- > > 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. 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 > [1] https://lore.kernel.org/all/202206221602.odN70SHs-lkp@intel.com/ > > [2] > https://lore.kernel.org/all/16f9a971.44e5.1817068ee3c.Coremail.windhl@126.com/ > > > Best regards, > Krzysztof >
On Thu, 16 Jun 2022 10:17:13 +0800, Liang He wrote:
> 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,
--
Heiko Stuebner <heiko@sntech.de>
At 2022-06-18 01:10:28, "Heiko Stuebner" <heiko@sntech.de> wrote: >On Thu, 16 Jun 2022 10:17:13 +0800, Liang He wrote: >> 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. Thanks very much for your effort. I am learning the coding style for kernel code. > >Best regards, >-- >Heiko Stuebner <heiko@sntech.de>
© 2016 - 2026 Red Hat, Inc.