Skip to content

Commit 2fbabea

Browse files
visitorckwbebarino
authored andcommitted
clk: mmp: pxa168: Fix memory leak in pxa168_clk_init()
In cases where mapping of mpmu/apmu/apbc registers fails, the code path does not handle the failure gracefully, potentially leading to a memory leak. This fix ensures proper cleanup by freeing the allocated memory for 'pxa_unit' before returning. Signed-off-by: Kuan-Wei Chiu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent bfbea9e commit 2fbabea

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/clk/mmp/clk-of-pxa168.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,21 @@ static void __init pxa168_clk_init(struct device_node *np)
308308
pxa_unit->mpmu_base = of_iomap(np, 0);
309309
if (!pxa_unit->mpmu_base) {
310310
pr_err("failed to map mpmu registers\n");
311+
kfree(pxa_unit);
311312
return;
312313
}
313314

314315
pxa_unit->apmu_base = of_iomap(np, 1);
315316
if (!pxa_unit->apmu_base) {
316317
pr_err("failed to map apmu registers\n");
318+
kfree(pxa_unit);
317319
return;
318320
}
319321

320322
pxa_unit->apbc_base = of_iomap(np, 2);
321323
if (!pxa_unit->apbc_base) {
322324
pr_err("failed to map apbc registers\n");
325+
kfree(pxa_unit);
323326
return;
324327
}
325328

0 commit comments

Comments
 (0)