2022-06-16 02:25:47

by Liang He

[permalink] [raw]
Subject: [PATCH v2] 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.

Signed-off-by: Liang He <[email protected]>
---
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


2022-06-17 17:28:41

by Heiko Stübner

[permalink] [raw]
Subject: Re: [PATCH v2] arm: mach-rockchip: (pm) Add missing of_node_put()

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 <[email protected]>

2022-06-18 02:59:40

by Liang He

[permalink] [raw]
Subject: Re:Re: [PATCH v2] arm: mach-rockchip: (pm) Add missing of_node_put()



At 2022-06-18 01:10:28, "Heiko Stuebner" <[email protected]> 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 <[email protected]>

2022-06-22 09:55:40

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2] arm: mach-rockchip: (pm) Add missing of_node_put()

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 <[email protected]>
> ---
> 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

2022-06-22 13:23:54

by Heiko Stübner

[permalink] [raw]
Subject: Re: [PATCH v2] arm: mach-rockchip: (pm) Add missing of_node_put()

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 <[email protected]>
> > ---
> > 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/[email protected]/
>
> [2]
> https://lore.kernel.org/all/[email protected]/
>
>
> Best regards,
> Krzysztof
>