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 <ping.bai@nxp.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20231009083922.1942971-1-ping.bai@nxp.com
This commit is contained in:
parent
078a5babf2
commit
8051a993ce
@ -434,12 +434,16 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
imxtm->base = of_iomap(np, 0);
|
imxtm->base = of_iomap(np, 0);
|
||||||
if (!imxtm->base)
|
if (!imxtm->base) {
|
||||||
return -ENXIO;
|
ret = -ENXIO;
|
||||||
|
goto err_kfree;
|
||||||
|
}
|
||||||
|
|
||||||
imxtm->irq = irq_of_parse_and_map(np, 0);
|
imxtm->irq = irq_of_parse_and_map(np, 0);
|
||||||
if (imxtm->irq <= 0)
|
if (imxtm->irq <= 0) {
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto err_kfree;
|
||||||
|
}
|
||||||
|
|
||||||
imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
|
imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
|
||||||
|
|
||||||
@ -452,11 +456,15 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t
|
|||||||
|
|
||||||
ret = _mxc_timer_init(imxtm);
|
ret = _mxc_timer_init(imxtm);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto err_kfree;
|
||||||
|
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_kfree:
|
||||||
|
kfree(imxtm);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init imx1_timer_init_dt(struct device_node *np)
|
static int __init imx1_timer_init_dt(struct device_node *np)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user