Skip to content

Commit

Permalink
clk: visconti: Fix memory leak in visconti_register_pll()
Browse files Browse the repository at this point in the history
[ Upstream commit b55226f ]

@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: b4cbe60 ("clk: visconti: Add support common clock driver and reset driver")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Link: https://lore.kernel.org/r/20221122152353.204132-1-xiujianfeng@huawei.com
Acked-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Xiu Jianfeng authored and gregkh committed Dec 31, 2022
1 parent 4fa98de commit f0f1982
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/clk/visconti/pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f0f1982

Please sign in to comment.