2022-10-29 12:17:11

by Yang Yingliang

[permalink] [raw]
Subject: [PATCH v2] clocksource/drivers/timer-ti-dm: fix missing clk_disable_unprepare in dmtimer_systimer_init_clock()

If clk_get_rate() fails which is called after clk_prepare_enable(),
clk_disable_unprepare() need be called in error path to disable the
clock in dmtimer_systimer_init_clock().

Fixes: 52762fbd1c47 ("clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support")
Signed-off-by: Yang Yingliang <[email protected]>
---
v1 -> v2:
Add fix tag.
v1 patch link:
https://lore.kernel.org/lkml/[email protected]/
---
drivers/clocksource/timer-ti-dm-systimer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-ti-dm-systimer.c b/drivers/clocksource/timer-ti-dm-systimer.c
index 2737407ff069..632523c1232f 100644
--- a/drivers/clocksource/timer-ti-dm-systimer.c
+++ b/drivers/clocksource/timer-ti-dm-systimer.c
@@ -345,8 +345,10 @@ static int __init dmtimer_systimer_init_clock(struct dmtimer_systimer *t,
return error;

r = clk_get_rate(clock);
- if (!r)
+ if (!r) {
+ clk_disable_unprepare(clock);
return -ENODEV;
+ }

if (is_ick)
t->ick = clock;
--
2.25.1



2022-10-31 08:55:36

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH v2] clocksource/drivers/timer-ti-dm: fix missing clk_disable_unprepare in dmtimer_systimer_init_clock()

* Yang Yingliang <[email protected]> [221029 11:36]:
> If clk_get_rate() fails which is called after clk_prepare_enable(),
> clk_disable_unprepare() need be called in error path to disable the
> clock in dmtimer_systimer_init_clock().

Reviewed-by: Tony Lindgren <[email protected]>

2022-12-09 15:52:28

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] clocksource/drivers/timer-ti-dm: Fix missing clk_disable_unprepare in dmtimer_systimer_init_clock()

The following commit has been merged into the timers/core branch of tip:

Commit-ID: 180d35a7c05d520314a590c99ad8643d0213f28b
Gitweb: https://git.kernel.org/tip/180d35a7c05d520314a590c99ad8643d0213f28b
Author: Yang Yingliang <[email protected]>
AuthorDate: Sat, 29 Oct 2022 19:44:27 +08:00
Committer: Daniel Lezcano <[email protected]>
CommitterDate: Fri, 02 Dec 2022 13:16:46 +01:00

clocksource/drivers/timer-ti-dm: Fix missing clk_disable_unprepare in dmtimer_systimer_init_clock()

If clk_get_rate() fails which is called after clk_prepare_enable(),
clk_disable_unprepare() need be called in error path to disable the
clock in dmtimer_systimer_init_clock().

Fixes: 52762fbd1c47 ("clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support")
Signed-off-by: Yang Yingliang <[email protected]>
Reviewed-by: Tony Lindgren <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Daniel Lezcano <[email protected]>
---
drivers/clocksource/timer-ti-dm-systimer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-ti-dm-systimer.c b/drivers/clocksource/timer-ti-dm-systimer.c
index 2737407..632523c 100644
--- a/drivers/clocksource/timer-ti-dm-systimer.c
+++ b/drivers/clocksource/timer-ti-dm-systimer.c
@@ -345,8 +345,10 @@ static int __init dmtimer_systimer_init_clock(struct dmtimer_systimer *t,
return error;

r = clk_get_rate(clock);
- if (!r)
+ if (!r) {
+ clk_disable_unprepare(clock);
return -ENODEV;
+ }

if (is_ick)
t->ick = clock;