All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: baihaowen <baihaowen@meizu.com>
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 12:39:52 +0200	[thread overview]
Message-ID: <CAMuHMdWa6fhG3Bmfeqo+FLbapqXAb+kYsXrM9wq5OAfBTrkbGg@mail.gmail.com> (raw)
In-Reply-To: <05f14aa0-4001-d08d-610e-12749437ec9a@meizu.com>

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

  reply	other threads:[~2022-04-13 10:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=CAMuHMdWa6fhG3Bmfeqo+FLbapqXAb+kYsXrM9wq5OAfBTrkbGg@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=baihaowen@meizu.com \
    --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 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.