clocksource: dw_apb_timer_of: add handling for potential memory leak
PATCH RESEND 1/1 clocksource: 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 kernel test robot <[email protected]>
Reported-by Dan Carpenter <[email protected]>
Signed-off-by Dinh Nguyen <[email protected]>
--- drivers/clocksource/dw_apb_timer_of.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/clocksource/dw_apb_timer_of.c +21 -5
@@ -52,18 +52,34 @@ static int __init timer_get_base_and_rate(struct device_node *np,return 0 ; timer_clk =of_clk_get_by_name (np,"timer" ); -if (IS_ERR (timer_clk)) -return PTR_ERR (timer_clk); +if (IS_ERR (timer_clk)) { + ret =PTR_ERR (timer_clk); + goto out_pclk_disable; + } ret =clk_prepare_enable (timer_clk);if (ret) -return ret; + goto out_timer_clk_put; *rate =clk_get_rate (timer_clk); -if (!(*rate)) -return -EINVAL ; +if (!(*rate)) { + ret = -EINVAL ; + goto out_timer_clk_disable; + }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)
Signature · 1 line
2.25.1
[tip: timers/core] clocksource/drivers/dw_apb_timer_of: Add handling for potential memory leak
The following commit has been merged into the timers/core branch of tip:
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 397dc6f7ca3c858dc95800f299357311ccf679e6 Gitweb: https://git.kernel.org/tip/397dc6f7ca3c858dc95800f299357311ccf679e6 Author: Dinh Nguyen <[email protected]> AuthorDate: Mon, 22 Mar 2021 07:18:44 -05:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Thu, 08 Apr 2021 13:24:53 +02:00
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 kernel test robot <[email protected]>
Reported-by Dan Carpenter <[email protected]>
Signed-off-by Dinh Nguyen <[email protected]>
Signed-off-by Daniel Lezcano <[email protected]>
--- drivers/clocksource/dw_apb_timer_of.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/clocksource/dw_apb_timer_of.c +21 -5
@@ -52,18 +52,34 @@ static int __init timer_get_base_and_rate(struct device_node *np,return 0 ; timer_clk =of_clk_get_by_name (np,"timer" ); -if (IS_ERR (timer_clk)) -return PTR_ERR (timer_clk); +if (IS_ERR (timer_clk)) { + ret =PTR_ERR (timer_clk); + goto out_pclk_disable; + } ret =clk_prepare_enable (timer_clk);if (ret) -return ret; + goto out_timer_clk_put; *rate =clk_get_rate (timer_clk); -if (!(*rate)) -return -EINVAL ; +if (!(*rate)) { + ret = -EINVAL ; + goto out_timer_clk_disable; + }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)