From: Brian Masney <bmasney@redhat.com>
To: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Cc: mturquette@baylibre.com, sboyd@kernel.org,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: st: clkgen-pll: Add a cleaup in clkgen_c32_pll_setup()
Date: Wed, 14 Jan 2026 19:41:50 -0500 [thread overview]
Message-ID: <aWg3ztytIYtkkDj-@redhat.com> (raw)
In-Reply-To: <20260107092250.3423379-1-lihaoxiang@isrc.iscas.ac.cn>
Hi Haoxiang,
The subject has a typo: 'cleaup' should be 'cleanup'. Several notes
below.
On Wed, Jan 07, 2026 at 05:22:50PM +0800, Haoxiang Li wrote:
> Add a iounmap() to release the memory allocated by
> clkgen_get_register_base().
>
> Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> ---
> drivers/clk/st/clkgen-pll.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/st/clkgen-pll.c b/drivers/clk/st/clkgen-pll.c
> index c258ff87a171..cc1dd9523fb2 100644
> --- a/drivers/clk/st/clkgen-pll.c
> +++ b/drivers/clk/st/clkgen-pll.c
> @@ -777,7 +777,7 @@ static void __init clkgen_c32_pll_setup(struct device_node *np,
> clk = clkgen_pll_register(parent_name, datac->data, pll_base, pll_flags,
> np->name, datac->data->lock);
> if (IS_ERR(clk))
> - return;
> + goto err_unmap;
>
> pll_name = __clk_get_name(clk);
>
> @@ -785,7 +785,7 @@ static void __init clkgen_c32_pll_setup(struct device_node *np,
>
> clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
> if (!clk_data)
> - return;
> + goto err_unmap;
These look fine, along with the err_unmap below. It looks like there's
several other leaks in this code though.
> clk_data->clk_num = num_odfs;
> clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *),
> @@ -827,6 +827,9 @@ static void __init clkgen_c32_pll_setup(struct device_node *np,
> kfree(pll_name);
^^^^^^^^^
I know this isn't part of your patch, however pll_name is actually the
return value from __clk_get_name(), which is name member from
struct device_node. Is that correct to free here in the case of an
error?
Additionaly, clkgen_pll_register() calls kzalloc() for struct
clkgen_pll, and it won't be freed on the error case.
In clkgen_c32_pll_setup():
> clk = clkgen_pll_register(parent_name, datac->data, pll_base, pll_flags,
> np->name, datac->data->lock);
> if (IS_ERR(clk))
> return;
>
> pll_name = __clk_get_name(clk);
>
> num_odfs = datac->data->num_odfs;
>
> clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
> if (!clk_data)
> return;
^^^ clk is not freed here, along with pll_base does not have
iounmap called on it.
Brian
prev parent reply other threads:[~2026-01-15 0:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 9:22 [PATCH] clk: st: clkgen-pll: Add a cleaup in clkgen_c32_pll_setup() Haoxiang Li
2026-01-15 0:41 ` Brian Masney [this message]
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=aWg3ztytIYtkkDj-@redhat.com \
--to=bmasney@redhat.com \
--cc=lihaoxiang@isrc.iscas.ac.cn \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@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