* [PATCH] powerpc/powermac/pfunc_base: Fix refcount leak bug in macio_gpio_init_one()
@ 2022-07-16 7:31 Liang He
2022-08-02 4:51 ` Benjamin Herrenschmidt
2022-09-09 12:07 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Liang He @ 2022-07-16 7:31 UTC (permalink / raw)
To: benh, mpe, paulus, linuxppc-dev, windhl
We should call of_node_put() for the reference 'gparent' escaped
out of the for_each_child_of_node() as it has increased the refcount.
Fixes: 5b9ca526917b ("[PATCH] 3/5 powerpc: Add platform functions interpreter")
Signed-off-by: Liang He <windhl@126.com>
---
arch/powerpc/platforms/powermac/pfunc_base.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/platforms/powermac/pfunc_base.c b/arch/powerpc/platforms/powermac/pfunc_base.c
index 9c2947a3edd5..085e0ad20eba 100644
--- a/arch/powerpc/platforms/powermac/pfunc_base.c
+++ b/arch/powerpc/platforms/powermac/pfunc_base.c
@@ -136,6 +136,8 @@ static void __init macio_gpio_init_one(struct macio_chip *macio)
for_each_child_of_node(gparent, gp)
pmf_do_functions(gp, NULL, 0, PMF_FLAGS_ON_INIT, NULL);
+ of_node_put(gparent);
+
/* Note: We do not at this point implement the "at sleep" or "at wake"
* functions. I yet to find any for GPIOs anyway
*/
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/powermac/pfunc_base: Fix refcount leak bug in macio_gpio_init_one()
2022-07-16 7:31 [PATCH] powerpc/powermac/pfunc_base: Fix refcount leak bug in macio_gpio_init_one() Liang He
@ 2022-08-02 4:51 ` Benjamin Herrenschmidt
2022-08-13 7:36 ` Liang He
2022-09-09 12:07 ` Michael Ellerman
1 sibling, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2022-08-02 4:51 UTC (permalink / raw)
To: Liang He, mpe, paulus, linuxppc-dev
On Sat, 2022-07-16 at 15:31 +0800, Liang He wrote:
> We should call of_node_put() for the reference 'gparent' escaped
> out of the for_each_child_of_node() as it has increased the refcount.
Same comment as before. That stuff happens once at boot, there's never
any dynamic allocation/deallocation of these, they just don't matter,
but feel free .... :-)
> Fixes: 5b9ca526917b ("[PATCH] 3/5 powerpc: Add platform functions
> interpreter")
> Signed-off-by: Liang He <windhl@126.com>
> ---
> arch/powerpc/platforms/powermac/pfunc_base.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/powerpc/platforms/powermac/pfunc_base.c
> b/arch/powerpc/platforms/powermac/pfunc_base.c
> index 9c2947a3edd5..085e0ad20eba 100644
> --- a/arch/powerpc/platforms/powermac/pfunc_base.c
> +++ b/arch/powerpc/platforms/powermac/pfunc_base.c
> @@ -136,6 +136,8 @@ static void __init macio_gpio_init_one(struct
> macio_chip *macio)
> for_each_child_of_node(gparent, gp)
> pmf_do_functions(gp, NULL, 0, PMF_FLAGS_ON_INIT, NULL);
>
> + of_node_put(gparent);
> +
> /* Note: We do not at this point implement the "at sleep" or
> "at wake"
> * functions. I yet to find any for GPIOs anyway
> */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re:Re: [PATCH] powerpc/powermac/pfunc_base: Fix refcount leak bug in macio_gpio_init_one()
2022-08-02 4:51 ` Benjamin Herrenschmidt
@ 2022-08-13 7:36 ` Liang He
0 siblings, 0 replies; 4+ messages in thread
From: Liang He @ 2022-08-13 7:36 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: paulus, linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 1480 bytes --]
At 2022-08-02 12:51:08, "Benjamin Herrenschmidt" <benh@kernel.crashing.org> wrote:
>On Sat, 2022-07-16 at 15:31 +0800, Liang He wrote:
>> We should call of_node_put() for the reference 'gparent' escaped
>> out of the for_each_child_of_node() as it has increased the refcount.
>
>Same comment as before. That stuff happens once at boot, there's never
>any dynamic allocation/deallocation of these, they just don't matter,
>but feel free .... :-)
>
Thanks for your reply, this is a valuable lesson for me.
I will now begin to learn the detailed difference of dynamic and static allocation.
Thanks,
Liang
>> Fixes: 5b9ca526917b ("[PATCH] 3/5 powerpc: Add platform functions
>> interpreter")
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>> arch/powerpc/platforms/powermac/pfunc_base.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/powerpc/platforms/powermac/pfunc_base.c
>> b/arch/powerpc/platforms/powermac/pfunc_base.c
>> index 9c2947a3edd5..085e0ad20eba 100644
>> --- a/arch/powerpc/platforms/powermac/pfunc_base.c
>> +++ b/arch/powerpc/platforms/powermac/pfunc_base.c
>> @@ -136,6 +136,8 @@ static void __init macio_gpio_init_one(struct
>> macio_chip *macio)
>> for_each_child_of_node(gparent, gp)
>> pmf_do_functions(gp, NULL, 0, PMF_FLAGS_ON_INIT, NULL);
>>
>> + of_node_put(gparent);
>> +
>> /* Note: We do not at this point implement the "at sleep" or
>> "at wake"
>> * functions. I yet to find any for GPIOs anyway
>> */
[-- Attachment #2: Type: text/html, Size: 1868 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/powermac/pfunc_base: Fix refcount leak bug in macio_gpio_init_one()
2022-07-16 7:31 [PATCH] powerpc/powermac/pfunc_base: Fix refcount leak bug in macio_gpio_init_one() Liang He
2022-08-02 4:51 ` Benjamin Herrenschmidt
@ 2022-09-09 12:07 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2022-09-09 12:07 UTC (permalink / raw)
To: linuxppc-dev, paulus, Liang He, benh, mpe
On Sat, 16 Jul 2022 15:31:11 +0800, Liang He wrote:
> We should call of_node_put() for the reference 'gparent' escaped
> out of the for_each_child_of_node() as it has increased the refcount.
>
>
Applied to powerpc/next.
[1/1] powerpc/powermac/pfunc_base: Fix refcount leak bug in macio_gpio_init_one()
https://git.kernel.org/powerpc/c/11373c933db20f8b6fd2cad27712e683ac9785f0
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-09 12:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-16 7:31 [PATCH] powerpc/powermac/pfunc_base: Fix refcount leak bug in macio_gpio_init_one() Liang He
2022-08-02 4:51 ` Benjamin Herrenschmidt
2022-08-13 7:36 ` Liang He
2022-09-09 12:07 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.