Commit 0d041add authored by Yi Wang's avatar Yi Wang Committed by Greg Kroah-Hartman

clk: boston: fix possible memory leak in clk_boston_setup()

[ Upstream commit 46fda5b5 ]

Smatch report warnings:
drivers/clk/imgtec/clk-boston.c:76 clk_boston_setup() warn: possible memory leak of 'onecell'
drivers/clk/imgtec/clk-boston.c:83 clk_boston_setup() warn: possible memory leak of 'onecell'
drivers/clk/imgtec/clk-boston.c:90 clk_boston_setup() warn: possible memory leak of 'onecell'

'onecell' is malloced in clk_boston_setup(), but not be freed
before leaving from the error handling cases.
Signed-off-by: default avatarYi Wang <wang.yi59@zte.com.cn>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 46602077
...@@ -73,27 +73,32 @@ static void __init clk_boston_setup(struct device_node *np) ...@@ -73,27 +73,32 @@ static void __init clk_boston_setup(struct device_node *np)
hw = clk_hw_register_fixed_rate(NULL, "input", NULL, 0, in_freq); hw = clk_hw_register_fixed_rate(NULL, "input", NULL, 0, in_freq);
if (IS_ERR(hw)) { if (IS_ERR(hw)) {
pr_err("failed to register input clock: %ld\n", PTR_ERR(hw)); pr_err("failed to register input clock: %ld\n", PTR_ERR(hw));
return; goto error;
} }
onecell->hws[BOSTON_CLK_INPUT] = hw; onecell->hws[BOSTON_CLK_INPUT] = hw;
hw = clk_hw_register_fixed_rate(NULL, "sys", "input", 0, sys_freq); hw = clk_hw_register_fixed_rate(NULL, "sys", "input", 0, sys_freq);
if (IS_ERR(hw)) { if (IS_ERR(hw)) {
pr_err("failed to register sys clock: %ld\n", PTR_ERR(hw)); pr_err("failed to register sys clock: %ld\n", PTR_ERR(hw));
return; goto error;
} }
onecell->hws[BOSTON_CLK_SYS] = hw; onecell->hws[BOSTON_CLK_SYS] = hw;
hw = clk_hw_register_fixed_rate(NULL, "cpu", "input", 0, cpu_freq); hw = clk_hw_register_fixed_rate(NULL, "cpu", "input", 0, cpu_freq);
if (IS_ERR(hw)) { if (IS_ERR(hw)) {
pr_err("failed to register cpu clock: %ld\n", PTR_ERR(hw)); pr_err("failed to register cpu clock: %ld\n", PTR_ERR(hw));
return; goto error;
} }
onecell->hws[BOSTON_CLK_CPU] = hw; onecell->hws[BOSTON_CLK_CPU] = hw;
err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, onecell); err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, onecell);
if (err) if (err)
pr_err("failed to add DT provider: %d\n", err); pr_err("failed to add DT provider: %d\n", err);
return;
error:
kfree(onecell);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment