Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk:mmp:clk-of-mmp2: Free memory and Unmap region obtained by kzalloc and of_iomap

Free memory and memory mapping , if mmp2_clk_init is not successful.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
[sboyd@codeaurora.org: Put return at the right place]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Arvind Yadav and committed by
Stephen Boyd
81ba3cc2 19b9f29d

+12 -3
+12 -3
drivers/clk/mmp/clk-of-mmp2.c
··· 309 309 pxa_unit->mpmu_base = of_iomap(np, 0); 310 310 if (!pxa_unit->mpmu_base) { 311 311 pr_err("failed to map mpmu registers\n"); 312 - return; 312 + goto free_memory; 313 313 } 314 314 315 315 pxa_unit->apmu_base = of_iomap(np, 1); 316 316 if (!pxa_unit->apmu_base) { 317 317 pr_err("failed to map apmu registers\n"); 318 - return; 318 + goto unmap_mpmu_region; 319 319 } 320 320 321 321 pxa_unit->apbc_base = of_iomap(np, 2); 322 322 if (!pxa_unit->apbc_base) { 323 323 pr_err("failed to map apbc registers\n"); 324 - return; 324 + goto unmap_apmu_region; 325 325 } 326 326 327 327 mmp_clk_init(np, &pxa_unit->unit, MMP2_NR_CLKS); ··· 333 333 mmp2_axi_periph_clk_init(pxa_unit); 334 334 335 335 mmp2_clk_reset_init(np, pxa_unit); 336 + 337 + return; 338 + 339 + unmap_apmu_region: 340 + iounmap(pxa_unit->apmu_base); 341 + unmap_mpmu_region: 342 + iounmap(pxa_unit->mpmu_base); 343 + free_memory: 344 + kfree(pxa_unit); 336 345 } 337 346 338 347 CLK_OF_DECLARE(mmp2_clk, "marvell,mmp2-clock", mmp2_clk_init);