Skip to content
Snippets Groups Projects
Commit 36200e4a authored by Zhang Qilong's avatar Zhang Qilong Committed by Greg Kroah-Hartman
Browse files

clk: ti: Fix memleak in ti_fapll_synth_setup


[ Upstream commit 8c6239f6 ]

If clk_register fails, we should goto free branch
before function returns to prevent memleak.

Fixes: 163152cb ("clk: ti: Add support for FAPLL on dm816x")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarZhang Qilong <zhangqilong3@huawei.com>
Link: https://lore.kernel.org/r/20201113131623.2098222-1-zhangqilong3@huawei.com


Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c3ae6afe
No related branches found
No related tags found
No related merge requests found
......@@ -497,6 +497,7 @@ static struct clk * __init ti_fapll_synth_setup(struct fapll_data *fd,
{
struct clk_init_data *init;
struct fapll_synth *synth;
struct clk *clk = ERR_PTR(-ENOMEM);
init = kzalloc(sizeof(*init), GFP_KERNEL);
if (!init)
......@@ -519,13 +520,19 @@ static struct clk * __init ti_fapll_synth_setup(struct fapll_data *fd,
synth->hw.init = init;
synth->clk_pll = pll_clk;
return clk_register(NULL, &synth->hw);
clk = clk_register(NULL, &synth->hw);
if (IS_ERR(clk)) {
pr_err("failed to register clock\n");
goto free;
}
return clk;
free:
kfree(synth);
kfree(init);
return ERR_PTR(-ENOMEM);
return clk;
}
static void __init ti_fapll_setup(struct device_node *node)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment