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/cadence-ttc: Fix memory leak in ttc_timer_probe

Smatch reports:
drivers/clocksource/timer-cadence-ttc.c:529 ttc_timer_probe()
warn: 'timer_baseaddr' from of_iomap() not released on lines: 498,508,516.

timer_baseaddr may have the problem of not being released after use,
I replaced it with the devm_of_iomap() function and added the clk_put()
function to cleanup the "clk_ce" and "clk_cs".

Fixes: e932900a3279 ("arm: zynq: Use standard timer binding")
Fixes: 70504f311d4b ("clocksource/drivers/cadence_ttc: Convert init function to return error")
Signed-off-by: Feng Mingxi <m202271825@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Acked-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230425065611.702917-1-m202271825@hust.edu.cn

authored by

Feng Mingxi and committed by
Daniel Lezcano
8b5bf64c 6d0d4df8

+13 -6
+13 -6
drivers/clocksource/timer-cadence-ttc.c
··· 486 486 * and use it. Note that the event timer uses the interrupt and it's the 487 487 * 2nd TTC hence the irq_of_parse_and_map(,1) 488 488 */ 489 - timer_baseaddr = of_iomap(timer, 0); 490 - if (!timer_baseaddr) { 489 + timer_baseaddr = devm_of_iomap(&pdev->dev, timer, 0, NULL); 490 + if (IS_ERR(timer_baseaddr)) { 491 491 pr_err("ERROR: invalid timer base address\n"); 492 - return -ENXIO; 492 + return PTR_ERR(timer_baseaddr); 493 493 } 494 494 495 495 irq = irq_of_parse_and_map(timer, 1); ··· 513 513 clk_ce = of_clk_get(timer, clksel); 514 514 if (IS_ERR(clk_ce)) { 515 515 pr_err("ERROR: timer input clock not found\n"); 516 - return PTR_ERR(clk_ce); 516 + ret = PTR_ERR(clk_ce); 517 + goto put_clk_cs; 517 518 } 518 519 519 520 ret = ttc_setup_clocksource(clk_cs, timer_baseaddr, timer_width); 520 521 if (ret) 521 - return ret; 522 + goto put_clk_ce; 522 523 523 524 ret = ttc_setup_clockevent(clk_ce, timer_baseaddr + 4, irq); 524 525 if (ret) 525 - return ret; 526 + goto put_clk_ce; 526 527 527 528 pr_info("%pOFn #0 at %p, irq=%d\n", timer, timer_baseaddr, irq); 528 529 529 530 return 0; 531 + 532 + put_clk_ce: 533 + clk_put(clk_ce); 534 + put_clk_cs: 535 + clk_put(clk_cs); 536 + return ret; 530 537 } 531 538 532 539 static const struct of_device_id ttc_timer_of_match[] = {