* [PATCH] clk: st: clkgen-pll: Add a cleaup in clkgen_c32_pll_setup()
@ 2026-01-07 9:22 Haoxiang Li
2026-01-15 0:41 ` Brian Masney
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-01-07 9:22 UTC (permalink / raw)
To: mturquette, sboyd, bmasney; +Cc: linux-clk, linux-kernel, Haoxiang Li
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;
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);
kfree(clk_data->clks);
kfree(clk_data);
+err_unmap:
+ if (pll_base)
+ iounmap(pll_base);
}
static void __init clkgen_c32_pll0_setup(struct device_node *np)
{
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: st: clkgen-pll: Add a cleaup in clkgen_c32_pll_setup()
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
0 siblings, 0 replies; 2+ messages in thread
From: Brian Masney @ 2026-01-15 0:41 UTC (permalink / raw)
To: Haoxiang Li; +Cc: mturquette, sboyd, linux-clk, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-15 0:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox