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/ralink: Fix resource leaks in init error path

The ralink_systick_init() function does not release all acquired resources
on its error paths. If irq_of_parse_and_map() or a subsequent call fails,
the previously created I/O memory mapping and IRQ mapping are leaked.

Add goto-based error handling labels to ensure that all allocated
resources are correctly freed.

Fixes: 1f2acc5a8a0a ("MIPS: ralink: Add support for systick timer found on newer ralink SoC")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://patch.msgid.link/20251030090710.1603-1-vulab@iscas.ac.cn

authored by

Haotian Zhang and committed by
Daniel Lezcano
2ba8e2aa 640594a0

+9 -2
+9 -2
drivers/clocksource/timer-ralink.c
··· 130 130 systick.dev.irq = irq_of_parse_and_map(np, 0); 131 131 if (!systick.dev.irq) { 132 132 pr_err("%pOFn: request_irq failed", np); 133 - return -EINVAL; 133 + ret = -EINVAL; 134 + goto err_iounmap; 134 135 } 135 136 136 137 ret = clocksource_mmio_init(systick.membase + SYSTICK_COUNT, np->name, 137 138 SYSTICK_FREQ, 301, 16, 138 139 clocksource_mmio_readl_up); 139 140 if (ret) 140 - return ret; 141 + goto err_free_irq; 141 142 142 143 clockevents_register_device(&systick.dev); 143 144 ··· 146 145 np, systick.dev.mult, systick.dev.shift); 147 146 148 147 return 0; 148 + 149 + err_free_irq: 150 + irq_dispose_mapping(systick.dev.irq); 151 + err_iounmap: 152 + iounmap(systick.membase); 153 + return ret; 149 154 } 150 155 151 156 TIMER_OF_DECLARE(systick, "ralink,cevt-systick", ralink_systick_init);