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

clocksource/drivers/mtk_timer: Fix memleak in mtk_timer_init()

Add error path to clear evt struct allocated by kzalloc() in the beginning of
function mtk_timer_init().

Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Alexey Klimov and committed by
Daniel Lezcano
11faa20e 6cd7ccaa

+3 -1
+3 -1
drivers/clocksource/mtk_timer.c
··· 205 205 evt->gpt_base = of_io_request_and_map(node, 0, "mtk-timer"); 206 206 if (IS_ERR(evt->gpt_base)) { 207 207 pr_err("Can't get resource\n"); 208 - return; 208 + goto err_kzalloc; 209 209 } 210 210 211 211 evt->dev.irq = irq_of_parse_and_map(node, 0); ··· 260 260 iounmap(evt->gpt_base); 261 261 of_address_to_resource(node, 0, &res); 262 262 release_mem_region(res.start, resource_size(&res)); 263 + err_kzalloc: 264 + kfree(evt); 263 265 } 264 266 CLOCKSOURCE_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_timer_init);