Skip to content

Commit 8051a99

Browse files
JackyBaidlezcano
authored andcommitted
clocksource/drivers/timer-imx-gpt: Fix potential memory leak
Fix coverity Issue CID 250382: Resource leak (RESOURCE_LEAK). Add kfree when error return. Signed-off-by: Jacky Bai <[email protected]> Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 078a5ba commit 8051a99

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/clocksource/timer-imx-gpt.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,16 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t
434434
return -ENOMEM;
435435

436436
imxtm->base = of_iomap(np, 0);
437-
if (!imxtm->base)
438-
return -ENXIO;
437+
if (!imxtm->base) {
438+
ret = -ENXIO;
439+
goto err_kfree;
440+
}
439441

440442
imxtm->irq = irq_of_parse_and_map(np, 0);
441-
if (imxtm->irq <= 0)
442-
return -EINVAL;
443+
if (imxtm->irq <= 0) {
444+
ret = -EINVAL;
445+
goto err_kfree;
446+
}
443447

444448
imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
445449

@@ -452,11 +456,15 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t
452456

453457
ret = _mxc_timer_init(imxtm);
454458
if (ret)
455-
return ret;
459+
goto err_kfree;
456460

457461
initialized = 1;
458462

459463
return 0;
464+
465+
err_kfree:
466+
kfree(imxtm);
467+
return ret;
460468
}
461469

462470
static int __init imx1_timer_init_dt(struct device_node *np)

0 commit comments

Comments
 (0)