* [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
@ 2022-04-13 8:19 Haowen Bai
2022-04-13 8:41 ` Geert Uytterhoeven
2022-04-14 9:29 ` Sergey Shtylyov
0 siblings, 2 replies; 10+ messages in thread
From: Haowen Bai @ 2022-04-13 8:19 UTC (permalink / raw)
To: Geert Uytterhoeven, Michael Turquette, Stephen Boyd
Cc: Haowen Bai, linux-renesas-soc, linux-clk, linux-kernel
Fix this issue by freeing the cpg when exiting the function in the
error/normal path.
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
V1->V2: free both cpg&clks.
drivers/clk/renesas/clk-r8a73a4.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/renesas/clk-r8a73a4.c b/drivers/clk/renesas/clk-r8a73a4.c
index cfed11c659d9..5a8d976f49e0 100644
--- a/drivers/clk/renesas/clk-r8a73a4.c
+++ b/drivers/clk/renesas/clk-r8a73a4.c
@@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
cpg->reg = of_iomap(np, 0);
if (WARN_ON(cpg->reg == NULL))
- return;
+ goto out_free_cpg;
for (i = 0; i < num_clks; ++i) {
const char *name;
@@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
}
of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
+out_free_cpg:
+ kfree(cpg);
+ kfree(clks);
}
CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks",
r8a73a4_cpg_clocks_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
2022-04-13 8:19 [PATCH V2] clk: renesas: Fix memory leak of 'cpg' Haowen Bai
@ 2022-04-13 8:41 ` Geert Uytterhoeven
2022-04-13 9:24 ` baihaowen
2022-04-14 9:29 ` Sergey Shtylyov
1 sibling, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2022-04-13 8:41 UTC (permalink / raw)
To: Haowen Bai
Cc: Michael Turquette, Stephen Boyd, Linux-Renesas, linux-clk,
Linux Kernel Mailing List
Hi Haowen,
On Wed, Apr 13, 2022 at 10:30 AM Haowen Bai <baihaowen@meizu.com> wrote:
> Fix this issue by freeing the cpg when exiting the function in the
> error/normal path.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Thanks for your patch!
> --- a/drivers/clk/renesas/clk-r8a73a4.c
> +++ b/drivers/clk/renesas/clk-r8a73a4.c
> @@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
>
> cpg->reg = of_iomap(np, 0);
> if (WARN_ON(cpg->reg == NULL))
> - return;
> + goto out_free_cpg;
Note that this is a fatal error, i.e. no chance the system will survive this,
so cleaning up is moot.
>
> for (i = 0; i < num_clks; ++i) {
> const char *name;
> @@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
> }
>
> of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
> +out_free_cpg:
> + kfree(cpg);
> + kfree(clks);
Both cpg and clks are still used after returning from this function,
through the registered clocks and clock provider.
> }
> CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks",
> r8a73a4_cpg_clocks_init);
NAKed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
2022-04-13 8:41 ` Geert Uytterhoeven
@ 2022-04-13 9:24 ` baihaowen
2022-04-13 10:39 ` Geert Uytterhoeven
0 siblings, 1 reply; 10+ messages in thread
From: baihaowen @ 2022-04-13 9:24 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Michael Turquette, Stephen Boyd, Linux-Renesas, linux-clk,
Linux Kernel Mailing List
在 4/13/22 4:41 PM, Geert Uytterhoeven 写道:
> Hi Haowen,
>
> On Wed, Apr 13, 2022 at 10:30 AM Haowen Bai <baihaowen@meizu.com> wrote:
>> Fix this issue by freeing the cpg when exiting the function in the
>> error/normal path.
>>
>> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> Thanks for your patch!
>
>> --- a/drivers/clk/renesas/clk-r8a73a4.c
>> +++ b/drivers/clk/renesas/clk-r8a73a4.c
>> @@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
>>
>> cpg->reg = of_iomap(np, 0);
>> if (WARN_ON(cpg->reg == NULL))
>> - return;
>> + goto out_free_cpg;
> Note that this is a fatal error, i.e. no chance the system will survive this,
> so cleaning up is moot.
>
>> for (i = 0; i < num_clks; ++i) {
>> const char *name;
>> @@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
>> }
>>
>> of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
>> +out_free_cpg:
>> + kfree(cpg);
>> + kfree(clks);
> Both cpg and clks are still used after returning from this function,
> through the registered clocks and clock provider.
>
>> }
>> CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks",
>> r8a73a4_cpg_clocks_init);
> NAKed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
Dear Geert Uytterhoeven
Could you show me how and when cpg & clks free ?
--
Haowen Bai
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
2022-04-13 9:24 ` baihaowen
@ 2022-04-13 10:39 ` Geert Uytterhoeven
0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2022-04-13 10:39 UTC (permalink / raw)
To: baihaowen
Cc: Michael Turquette, Stephen Boyd, Linux-Renesas, linux-clk,
Linux Kernel Mailing List
Hi Haowen,
On Wed, Apr 13, 2022 at 11:24 AM baihaowen <baihaowen@meizu.com> wrote:
> 在 4/13/22 4:41 PM, Geert Uytterhoeven 写道:
> > On Wed, Apr 13, 2022 at 10:30 AM Haowen Bai <baihaowen@meizu.com> wrote:
> >> Fix this issue by freeing the cpg when exiting the function in the
> >> error/normal path.
> >>
> >> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> > Thanks for your patch!
> >
> >> --- a/drivers/clk/renesas/clk-r8a73a4.c
> >> +++ b/drivers/clk/renesas/clk-r8a73a4.c
> >> @@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
> >>
> >> cpg->reg = of_iomap(np, 0);
> >> if (WARN_ON(cpg->reg == NULL))
> >> - return;
> >> + goto out_free_cpg;
> > Note that this is a fatal error, i.e. no chance the system will survive this,
> > so cleaning up is moot.
> >
> >> for (i = 0; i < num_clks; ++i) {
> >> const char *name;
> >> @@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
> >> }
> >>
> >> of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
> >> +out_free_cpg:
> >> + kfree(cpg);
> >> + kfree(clks);
> > Both cpg and clks are still used after returning from this function,
> > through the registered clocks and clock provider.
> >
> >> }
> >> CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks",
> >> r8a73a4_cpg_clocks_init);
> > NAKed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Could you show me how and when cpg & clks free ?
They are never freed, as they stay in-use for the lifetime of the system.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
2022-04-13 8:19 [PATCH V2] clk: renesas: Fix memory leak of 'cpg' Haowen Bai
2022-04-13 8:41 ` Geert Uytterhoeven
@ 2022-04-14 9:29 ` Sergey Shtylyov
2022-04-14 9:31 ` baihaowen
2022-04-14 9:32 ` Geert Uytterhoeven
1 sibling, 2 replies; 10+ messages in thread
From: Sergey Shtylyov @ 2022-04-14 9:29 UTC (permalink / raw)
To: Haowen Bai, Geert Uytterhoeven, Michael Turquette, Stephen Boyd
Cc: linux-renesas-soc, linux-clk, linux-kernel
Hello!
On 4/13/22 11:19 AM, Haowen Bai wrote:
> Fix this issue by freeing the cpg when exiting the function in the
> error/normal path.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
> V1->V2: free both cpg&clks.
>
> drivers/clk/renesas/clk-r8a73a4.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
2 patches with the same name won't do -- you always need to include the chip name
part of the file name in the subject (in this case r8a73a4).
MBR, Sergey
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
2022-04-14 9:29 ` Sergey Shtylyov
@ 2022-04-14 9:31 ` baihaowen
2022-04-14 9:32 ` Geert Uytterhoeven
1 sibling, 0 replies; 10+ messages in thread
From: baihaowen @ 2022-04-14 9:31 UTC (permalink / raw)
To: Sergey Shtylyov, Geert Uytterhoeven, Michael Turquette, Stephen Boyd
Cc: linux-renesas-soc, linux-clk, linux-kernel
在 4/14/22 5:29 PM, Sergey Shtylyov 写道:
> Hello!
>
> On 4/13/22 11:19 AM, Haowen Bai wrote:
>
>> Fix this issue by freeing the cpg when exiting the function in the
>> error/normal path.
>>
>> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
>> ---
>> V1->V2: free both cpg&clks.
>>
>> drivers/clk/renesas/clk-r8a73a4.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
> 2 patches with the same name won't do -- you always need to include the chip name
> part of the file name in the subject (in this case r8a73a4).
>
> MBR, Sergey
Got it, thank you for your kindly reminder.
--
Haowen Bai
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
2022-04-14 9:29 ` Sergey Shtylyov
2022-04-14 9:31 ` baihaowen
@ 2022-04-14 9:32 ` Geert Uytterhoeven
2022-04-14 18:26 ` Sergey Shtylyov
1 sibling, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2022-04-14 9:32 UTC (permalink / raw)
To: Sergey Shtylyov
Cc: Haowen Bai, Michael Turquette, Stephen Boyd, Linux-Renesas,
linux-clk, Linux Kernel Mailing List
Hi Sergei,
On Thu, Apr 14, 2022 at 11:29 AM Sergey Shtylyov <s.shtylyov@omp.ru> wrote:
> On 4/13/22 11:19 AM, Haowen Bai wrote:
> > Fix this issue by freeing the cpg when exiting the function in the
> > error/normal path.
> >
> > Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> > ---
> > V1->V2: free both cpg&clks.
> >
> > drivers/clk/renesas/clk-r8a73a4.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 2 patches with the same name won't do -- you always need to include the chip name
> part of the file name in the subject (in this case r8a73a4).
Oh, they were for multiple drivers?
I hadn't even noticed , as Gmail collapsed them all into the same thread...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
2022-04-14 9:32 ` Geert Uytterhoeven
@ 2022-04-14 18:26 ` Sergey Shtylyov
0 siblings, 0 replies; 10+ messages in thread
From: Sergey Shtylyov @ 2022-04-14 18:26 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Haowen Bai, Michael Turquette, Stephen Boyd, Linux-Renesas,
linux-clk, Linux Kernel Mailing List
On 4/14/22 12:32 PM, Geert Uytterhoeven wrote:
[...]
>>> Fix this issue by freeing the cpg when exiting the function in the
>>> error/normal path.
>>>
>>> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
>>> ---
>>> V1->V2: free both cpg&clks.
>>>
>>> drivers/clk/renesas/clk-r8a73a4.c | 5 ++++-
>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> 2 patches with the same name won't do -- you always need to include the chip name
>> part of the file name in the subject (in this case r8a73a4).
>
> Oh, they were for multiple drivers?
I counted 3! :-)
> I hadn't even noticed , as Gmail collapsed them all into the same thread...
Hm, they weren't actually posted in the same thread...
> Gr{oetje,eeting}s,
>
> Geert
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <8dvhtgydaq7tflf8q4rq4fpu.1649846600874@email.android.com>]
* Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
[not found] <8dvhtgydaq7tflf8q4rq4fpu.1649846600874@email.android.com>
@ 2022-04-13 11:23 ` Geert Uytterhoeven
0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2022-04-13 11:23 UTC (permalink / raw)
To: 白浩文
Cc: Michael Turquette, Stephen Boyd, Linux-Renesas, linux-clk,
Linux Kernel Mailing List
Hi Haowen,
On Wed, Apr 13, 2022 at 12:44 PM 白浩文 <baihaowen@meizu.com> wrote:
> But this function __init r8a73a4_cpg_clocks_init will auto free by system after boot
The memory containing the code for the function
r8a73a4_cpg_clocks_init() will indeed be freed. But the data
structures allocated and prepared by the function will continue to
exist afterwards.
> On Wed, Apr 13, 2022 at 11:24 AM baihaowen <baihaowen@meizu.com> wrote:
> > 在 4/13/22 4:41 PM, Geert Uytterhoeven 写道:
> > > On Wed, Apr 13, 2022 at 10:30 AM Haowen Bai <baihaowen@meizu.com> wrote:
> > >> Fix this issue by freeing the cpg when exiting the function in the
> > >> error/normal path.
> > >>
> > >> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> > >> --- a/drivers/clk/renesas/clk-r8a73a4.c
> > >> +++ b/drivers/clk/renesas/clk-r8a73a4.c
> > >> @@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
> > >>
> > >> cpg->reg = of_iomap(np, 0);
> > >> if (WARN_ON(cpg->reg == NULL))
> > >> - return;
> > >> + goto out_free_cpg;
> > > Note that this is a fatal error, i.e. no chance the system will survive this,
> > > so cleaning up is moot.
> > >
> > >> for (i = 0; i < num_clks; ++i) {
> > >> const char *name;
> > >> @@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
> > >> }
> > >>
> > >> of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
> > >> +out_free_cpg:
> > >> + kfree(cpg);
> > >> + kfree(clks);
> > > Both cpg and clks are still used after returning from this function,
> > > through the registered clocks and clock provider.
> > >
> > >> }
> > >> CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks",
> > >> r8a73a4_cpg_clocks_init);
> > > NAKed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> > Could you show me how and when cpg & clks free ?
>
> They are never freed, as they stay in-use for the lifetime of the system.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
@ 2022-04-13 8:16 Haowen Bai
0 siblings, 0 replies; 10+ messages in thread
From: Haowen Bai @ 2022-04-13 8:16 UTC (permalink / raw)
To: Geert Uytterhoeven, Michael Turquette, Stephen Boyd
Cc: Haowen Bai, linux-renesas-soc, linux-clk, linux-kernel
Fix this issue by freeing the cpg when exiting the function in the
error/normal path.
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
V1->V2: free both cpg&clks
drivers/clk/renesas/clk-r8a73a4.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/renesas/clk-r8a73a4.c b/drivers/clk/renesas/clk-r8a73a4.c
index cfed11c659d9..5a8d976f49e0 100644
--- a/drivers/clk/renesas/clk-r8a73a4.c
+++ b/drivers/clk/renesas/clk-r8a73a4.c
@@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
cpg->reg = of_iomap(np, 0);
if (WARN_ON(cpg->reg == NULL))
- return;
+ goto out_free_cpg;
for (i = 0; i < num_clks; ++i) {
const char *name;
@@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
}
of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
+out_free_cpg:
+ kfree(cpg);
+ kfree(clks);
}
CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks",
r8a73a4_cpg_clocks_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-04-14 18:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13 8:19 [PATCH V2] clk: renesas: Fix memory leak of 'cpg' Haowen Bai
2022-04-13 8:41 ` Geert Uytterhoeven
2022-04-13 9:24 ` baihaowen
2022-04-13 10:39 ` Geert Uytterhoeven
2022-04-14 9:29 ` Sergey Shtylyov
2022-04-14 9:31 ` baihaowen
2022-04-14 9:32 ` Geert Uytterhoeven
2022-04-14 18:26 ` Sergey Shtylyov
[not found] <8dvhtgydaq7tflf8q4rq4fpu.1649846600874@email.android.com>
2022-04-13 11:23 ` Geert Uytterhoeven
-- strict thread matches above, loose matches on Subject: below --
2022-04-13 8:16 Haowen Bai
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.