From: Heiko Stuebner <heiko@sntech.de>
To: mturquette@baylibre.com, sboyd@kernel.org, mturquette@linaro.org,
Xiu Jianfeng <xiujianfeng@huawei.com>
Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: rockchip: Fix memory leak in rockchip_clk_register_pll()
Date: Wed, 23 Nov 2022 10:01:30 +0100 [thread overview]
Message-ID: <6301679.31r3eYUQgx@phil> (raw)
In-Reply-To: <20221123032237.64567-1-xiujianfeng@huawei.com>
Hi,
Am Mittwoch, 23. November 2022, 04:22:37 CET schrieb Xiu Jianfeng:
> If clk_register() fails, @pll->rate_table may have allocated memory by
> kmemdup(), so it needs to be freed, otherwise will cause memory leak
> issue, this patch fixes it.
>
> Fixes: 90c590254051 ("clk: rockchip: add clock type for pll clocks and pll used on rk3066")
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> ---
> drivers/clk/rockchip/clk-pll.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
> index 4b9840994295..dc4ce280d125 100644
> --- a/drivers/clk/rockchip/clk-pll.c
> +++ b/drivers/clk/rockchip/clk-pll.c
> @@ -1200,6 +1200,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
> clk_unregister(mux_clk);
> mux_clk = pll_clk;
> err_mux:
> + kfree(pll->rate_table);
I think this free needs to go up to the err_pll block.
In the code it is
- clk_register(pll_mux->hw) -> err_mux
- kmemdup
- clk_register(pll->hw) -> err_pll
so the kfree for the rate-table should probably
be at
err_pll:
kfree(rate_table)
clk_unregister(mux_clk);
...
Heiko
> kfree(pll);
> return mux_clk;
> }
>
next prev parent reply other threads:[~2022-11-23 9:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 3:22 [PATCH] clk: rockchip: Fix memory leak in rockchip_clk_register_pll() Xiu Jianfeng
2022-11-23 9:01 ` Heiko Stuebner [this message]
2022-11-23 9:21 ` xiujianfeng
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=6301679.31r3eYUQgx@phil \
--to=heiko@sntech.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mturquette@baylibre.com \
--cc=mturquette@linaro.org \
--cc=sboyd@kernel.org \
--cc=xiujianfeng@huawei.com \
/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