diff mbox

[RFC,3/3] clocksource: mtk_timer: fix memleak in mtk_timer_init()

Message ID 1441336900-15095-3-git-send-email-alexey.klimov@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Alexey Klimov Sept. 4, 2015, 3:21 a.m. UTC
Add error path to clear evt struct allocated by kzalloc()
in the beginning of function mtk_timer_init().

Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
---
 drivers/clocksource/mtk_timer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Matthias Brugger Sept. 4, 2015, 8:39 a.m. UTC | #1
On 04/09/15 05:21, Alexey Klimov wrote:
> Add error path to clear evt struct allocated by kzalloc()
> in the beginning of function mtk_timer_init().
>
> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
> ---
>   drivers/clocksource/mtk_timer.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
> index fbaacbf..9c5a2cc 100644
> --- a/drivers/clocksource/mtk_timer.c
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -201,7 +201,7 @@ static void __init mtk_timer_init(struct device_node *node)
>   	evt->gpt_base = of_io_request_and_map(node, 0, "mtk-timer");
>   	if (IS_ERR(evt->gpt_base)) {
>   		pr_err("Can't get resource\n");
> -		return;
> +		goto err_kzalloc;
>   	}
>
>   	evt->dev.irq = irq_of_parse_and_map(node, 0);
> @@ -256,5 +256,7 @@ err_mem:
>   	iounmap(evt->gpt_base);
>   	of_address_to_resource(node, 0, &res);
>   	release_mem_region(res.start, resource_size(&res));
> +err_kzalloc:
> +	kfree(evt);
>   }
>   CLOCKSOURCE_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_timer_init);
>

Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
diff mbox

Patch

diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
index fbaacbf..9c5a2cc 100644
--- a/drivers/clocksource/mtk_timer.c
+++ b/drivers/clocksource/mtk_timer.c
@@ -201,7 +201,7 @@  static void __init mtk_timer_init(struct device_node *node)
 	evt->gpt_base = of_io_request_and_map(node, 0, "mtk-timer");
 	if (IS_ERR(evt->gpt_base)) {
 		pr_err("Can't get resource\n");
-		return;
+		goto err_kzalloc;
 	}
 
 	evt->dev.irq = irq_of_parse_and_map(node, 0);
@@ -256,5 +256,7 @@  err_mem:
 	iounmap(evt->gpt_base);
 	of_address_to_resource(node, 0, &res);
 	release_mem_region(res.start, resource_size(&res));
+err_kzalloc:
+	kfree(evt);
 }
 CLOCKSOURCE_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_timer_init);