提交 c76a024e 编写于 作者: D David Dueck 提交者: Stephen Boyd

clk: at91: do not leak resources

Do not leak memory and free irqs in case of an error.
Acked-by: NBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: NDavid Dueck <davidcdueck@googlemail.com>
Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
上级 15ab3827
......@@ -116,8 +116,10 @@ void __init of_sama5d4_clk_h32mx_setup(struct device_node *np,
h32mxclk->pmc = pmc;
clk = clk_register(NULL, &h32mxclk->hw);
if (!clk)
if (!clk) {
kfree(h32mxclk);
return;
}
of_clk_add_provider(np, of_clk_src_simple_get, clk);
}
......@@ -171,8 +171,10 @@ at91_clk_register_main_osc(struct at91_pmc *pmc,
irq_set_status_flags(osc->irq, IRQ_NOAUTOEN);
ret = request_irq(osc->irq, clk_main_osc_irq_handler,
IRQF_TRIGGER_HIGH, name, osc);
if (ret)
if (ret) {
kfree(osc);
return ERR_PTR(ret);
}
if (bypass)
pmc_write(pmc, AT91_CKGR_MOR,
......
......@@ -165,12 +165,16 @@ at91_clk_register_master(struct at91_pmc *pmc, unsigned int irq,
irq_set_status_flags(master->irq, IRQ_NOAUTOEN);
ret = request_irq(master->irq, clk_master_irq_handler,
IRQF_TRIGGER_HIGH, "clk-master", master);
if (ret)
if (ret) {
kfree(master);
return ERR_PTR(ret);
}
clk = clk_register(NULL, &master->hw);
if (IS_ERR(clk))
if (IS_ERR(clk)) {
free_irq(master->irq, master);
kfree(master);
}
return clk;
}
......
......@@ -338,12 +338,16 @@ at91_clk_register_pll(struct at91_pmc *pmc, unsigned int irq, const char *name,
irq_set_status_flags(pll->irq, IRQ_NOAUTOEN);
ret = request_irq(pll->irq, clk_pll_irq_handler, IRQF_TRIGGER_HIGH,
id ? "clk-pllb" : "clk-plla", pll);
if (ret)
if (ret) {
kfree(pll);
return ERR_PTR(ret);
}
clk = clk_register(NULL, &pll->hw);
if (IS_ERR(clk))
if (IS_ERR(clk)) {
free_irq(pll->irq, pll);
kfree(pll);
}
return clk;
}
......
......@@ -130,13 +130,17 @@ at91_clk_register_system(struct at91_pmc *pmc, const char *name,
irq_set_status_flags(sys->irq, IRQ_NOAUTOEN);
ret = request_irq(sys->irq, clk_system_irq_handler,
IRQF_TRIGGER_HIGH, name, sys);
if (ret)
if (ret) {
kfree(sys);
return ERR_PTR(ret);
}
}
clk = clk_register(NULL, &sys->hw);
if (IS_ERR(clk))
if (IS_ERR(clk)) {
free_irq(sys->irq, sys);
kfree(sys);
}
return clk;
}
......
......@@ -118,12 +118,16 @@ at91_clk_register_utmi(struct at91_pmc *pmc, unsigned int irq,
irq_set_status_flags(utmi->irq, IRQ_NOAUTOEN);
ret = request_irq(utmi->irq, clk_utmi_irq_handler,
IRQF_TRIGGER_HIGH, "clk-utmi", utmi);
if (ret)
if (ret) {
kfree(utmi);
return ERR_PTR(ret);
}
clk = clk_register(NULL, &utmi->hw);
if (IS_ERR(clk))
if (IS_ERR(clk)) {
free_irq(utmi->irq, utmi);
kfree(utmi);
}
return clk;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册