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

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Jacky Bai and committed by
Daniel Lezcano
8051a993 078a5bab

+13 -5
+13 -5
drivers/clocksource/timer-imx-gpt.c
··· 434 434 return -ENOMEM; 435 435 436 436 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 + } 439 441 440 442 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 + } 443 447 444 448 imxtm->clk_ipg = of_clk_get_by_name(np, "ipg"); 445 449 ··· 456 452 457 453 ret = _mxc_timer_init(imxtm); 458 454 if (ret) 459 - return ret; 455 + goto err_kfree; 460 456 461 457 initialized = 1; 462 458 463 459 return 0; 460 + 461 + err_kfree: 462 + kfree(imxtm); 463 + return ret; 464 464 } 465 465 466 466 static int __init imx1_timer_init_dt(struct device_node *np)