From: baihaowen <baihaowen@meizu.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
linux-clk <linux-clk@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] clk: renesas: Fix memory leak of 'cpg'
Date: Wed, 13 Apr 2022 17:24:33 +0800 [thread overview]
Message-ID: <05f14aa0-4001-d08d-610e-12749437ec9a@meizu.com> (raw)
In-Reply-To: <CAMuHMdXcNBq5e6K6YUorLCF0hiFsp6VVKrUcy5E4mdAQAbH7Sg@mail.gmail.com>
在 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
next prev parent reply other threads:[~2022-04-13 9:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 8:19 Haowen Bai
2022-04-13 8:41 ` Geert Uytterhoeven
2022-04-13 9:24 ` baihaowen [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05f14aa0-4001-d08d-610e-12749437ec9a@meizu.com \
--to=baihaowen@meizu.com \
--cc=geert@linux-m68k.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®