MIPS: Alchemy: Fix memleak in alchemy_clk_setup_cpu
[ Upstream commit5.4-rM2-2.2.x-imx-squashedac3b57adf8
] If the clk_register fails, we should free h before function returns to prevent memleak. Fixes:474402291a
("MIPS: Alchemy: clock framework integration of onchip clocks") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
parent
cb5ad04eee
commit
5e7f422c38
|
@ -152,6 +152,7 @@ static struct clk __init *alchemy_clk_setup_cpu(const char *parent_name,
|
||||||
{
|
{
|
||||||
struct clk_init_data id;
|
struct clk_init_data id;
|
||||||
struct clk_hw *h;
|
struct clk_hw *h;
|
||||||
|
struct clk *clk;
|
||||||
|
|
||||||
h = kzalloc(sizeof(*h), GFP_KERNEL);
|
h = kzalloc(sizeof(*h), GFP_KERNEL);
|
||||||
if (!h)
|
if (!h)
|
||||||
|
@ -164,7 +165,13 @@ static struct clk __init *alchemy_clk_setup_cpu(const char *parent_name,
|
||||||
id.ops = &alchemy_clkops_cpu;
|
id.ops = &alchemy_clkops_cpu;
|
||||||
h->init = &id;
|
h->init = &id;
|
||||||
|
|
||||||
return clk_register(NULL, h);
|
clk = clk_register(NULL, h);
|
||||||
|
if (IS_ERR(clk)) {
|
||||||
|
pr_err("failed to register clock\n");
|
||||||
|
kfree(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return clk;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AUXPLLs ************************************************************/
|
/* AUXPLLs ************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue