Commit 397dc6f7 authored by Dinh Nguyen's avatar Dinh Nguyen Committed by Daniel Lezcano

clocksource/drivers/dw_apb_timer_of: Add handling for potential memory leak

Add calls to disable the clock and unmap the timer base address in case
of any failures.
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDinh Nguyen <dinguyen@kernel.org>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210322121844.2271041-1-dinguyen@kernel.org
parent 690daddc
...@@ -52,18 +52,34 @@ static int __init timer_get_base_and_rate(struct device_node *np, ...@@ -52,18 +52,34 @@ static int __init timer_get_base_and_rate(struct device_node *np,
return 0; return 0;
timer_clk = of_clk_get_by_name(np, "timer"); timer_clk = of_clk_get_by_name(np, "timer");
if (IS_ERR(timer_clk)) if (IS_ERR(timer_clk)) {
return PTR_ERR(timer_clk); ret = PTR_ERR(timer_clk);
goto out_pclk_disable;
}
ret = clk_prepare_enable(timer_clk); ret = clk_prepare_enable(timer_clk);
if (ret) if (ret)
return ret; goto out_timer_clk_put;
*rate = clk_get_rate(timer_clk); *rate = clk_get_rate(timer_clk);
if (!(*rate)) if (!(*rate)) {
return -EINVAL; ret = -EINVAL;
goto out_timer_clk_disable;
}
return 0; return 0;
out_timer_clk_disable:
clk_disable_unprepare(timer_clk);
out_timer_clk_put:
clk_put(timer_clk);
out_pclk_disable:
if (!IS_ERR(pclk)) {
clk_disable_unprepare(pclk);
clk_put(pclk);
}
iounmap(*base);
return ret;
} }
static int __init add_clockevent(struct device_node *event_timer) static int __init add_clockevent(struct device_node *event_timer)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment