From: Xiu Jianfeng Date: Tue, 22 Nov 2022 15:23:53 +0000 (+0800) Subject: clk: visconti: Fix memory leak in visconti_register_pll() X-Git-Tag: v6.1.8~1522 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0f1982ddfb418bf7bf05dadebae5c6869a41d41;p=platform%2Fkernel%2Flinux-starfive.git clk: visconti: Fix memory leak in visconti_register_pll() [ Upstream commit b55226f8553d255f5002c751c7c6ba9291f34bf2 ] @pll->rate_table has allocated memory by kmemdup(), if clk_hw_register() fails, it should be freed, otherwise it will cause memory leak issue, this patch fixes it. Fixes: b4cbe606dc36 ("clk: visconti: Add support common clock driver and reset driver") Signed-off-by: Xiu Jianfeng Link: https://lore.kernel.org/r/20221122152353.204132-1-xiujianfeng@huawei.com Acked-by: Nobuhiro Iwamatsu Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- diff --git a/drivers/clk/visconti/pll.c b/drivers/clk/visconti/pll.c index a484cb9..1f3234f 100644 --- a/drivers/clk/visconti/pll.c +++ b/drivers/clk/visconti/pll.c @@ -277,6 +277,7 @@ static struct clk_hw *visconti_register_pll(struct visconti_pll_provider *ctx, ret = clk_hw_register(NULL, &pll->hw); if (ret) { pr_err("failed to register pll clock %s : %d\n", name, ret); + kfree(pll->rate_table); kfree(pll); pll_hw_clk = ERR_PTR(ret); }