clk: at91: do not leak resources

Do not leak memory and free irqs in case of an error.

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: David Dueck <davidcdueck@googlemail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
This commit is contained in:
David Dueck 2015-06-26 15:30:22 +02:00 коммит произвёл Stephen Boyd
Родитель 15ab38273d
Коммит c76a024e82
6 изменённых файлов: 30 добавлений и 10 удалений

Просмотреть файл

@ -116,8 +116,10 @@ void __init of_sama5d4_clk_h32mx_setup(struct device_node *np,
h32mxclk->pmc = pmc; h32mxclk->pmc = pmc;
clk = clk_register(NULL, &h32mxclk->hw); clk = clk_register(NULL, &h32mxclk->hw);
if (!clk) if (!clk) {
kfree(h32mxclk);
return; return;
}
of_clk_add_provider(np, of_clk_src_simple_get, clk); 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); irq_set_status_flags(osc->irq, IRQ_NOAUTOEN);
ret = request_irq(osc->irq, clk_main_osc_irq_handler, ret = request_irq(osc->irq, clk_main_osc_irq_handler,
IRQF_TRIGGER_HIGH, name, osc); IRQF_TRIGGER_HIGH, name, osc);
if (ret) if (ret) {
kfree(osc);
return ERR_PTR(ret); return ERR_PTR(ret);
}
if (bypass) if (bypass)
pmc_write(pmc, AT91_CKGR_MOR, 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); irq_set_status_flags(master->irq, IRQ_NOAUTOEN);
ret = request_irq(master->irq, clk_master_irq_handler, ret = request_irq(master->irq, clk_master_irq_handler,
IRQF_TRIGGER_HIGH, "clk-master", master); IRQF_TRIGGER_HIGH, "clk-master", master);
if (ret) if (ret) {
kfree(master);
return ERR_PTR(ret); return ERR_PTR(ret);
}
clk = clk_register(NULL, &master->hw); clk = clk_register(NULL, &master->hw);
if (IS_ERR(clk)) if (IS_ERR(clk)) {
free_irq(master->irq, master);
kfree(master); kfree(master);
}
return clk; 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); irq_set_status_flags(pll->irq, IRQ_NOAUTOEN);
ret = request_irq(pll->irq, clk_pll_irq_handler, IRQF_TRIGGER_HIGH, ret = request_irq(pll->irq, clk_pll_irq_handler, IRQF_TRIGGER_HIGH,
id ? "clk-pllb" : "clk-plla", pll); id ? "clk-pllb" : "clk-plla", pll);
if (ret) if (ret) {
kfree(pll);
return ERR_PTR(ret); return ERR_PTR(ret);
}
clk = clk_register(NULL, &pll->hw); clk = clk_register(NULL, &pll->hw);
if (IS_ERR(clk)) if (IS_ERR(clk)) {
free_irq(pll->irq, pll);
kfree(pll); kfree(pll);
}
return clk; 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); irq_set_status_flags(sys->irq, IRQ_NOAUTOEN);
ret = request_irq(sys->irq, clk_system_irq_handler, ret = request_irq(sys->irq, clk_system_irq_handler,
IRQF_TRIGGER_HIGH, name, sys); IRQF_TRIGGER_HIGH, name, sys);
if (ret) if (ret) {
kfree(sys);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
}
clk = clk_register(NULL, &sys->hw); clk = clk_register(NULL, &sys->hw);
if (IS_ERR(clk)) if (IS_ERR(clk)) {
free_irq(sys->irq, sys);
kfree(sys); kfree(sys);
}
return clk; 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); irq_set_status_flags(utmi->irq, IRQ_NOAUTOEN);
ret = request_irq(utmi->irq, clk_utmi_irq_handler, ret = request_irq(utmi->irq, clk_utmi_irq_handler,
IRQF_TRIGGER_HIGH, "clk-utmi", utmi); IRQF_TRIGGER_HIGH, "clk-utmi", utmi);
if (ret) if (ret) {
kfree(utmi);
return ERR_PTR(ret); return ERR_PTR(ret);
}
clk = clk_register(NULL, &utmi->hw); clk = clk_register(NULL, &utmi->hw);
if (IS_ERR(clk)) if (IS_ERR(clk)) {
free_irq(utmi->irq, utmi);
kfree(utmi); kfree(utmi);
}
return clk; return clk;
} }