Skip to contentSkip to conversation

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

PATCH Applied Yang Yingliang 3 participants 3 messages Oct 29, 2022 – Dec 9, 2022 Clocksource, clockevent drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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")

---
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(-)
drivers/clocksource/timer-ti-dm-systimer.c +3 -1
index 2737407ff069..632523c1232f 100644
@@ -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;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 3 lines · Yang Yingliang

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().

merge bot Applied
#2 lore raw

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

In reply to Yang Yingliang
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:     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")
---
 drivers/clocksource/timer-ti-dm-systimer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/timer-ti-dm-systimer.c +3 -1
index 2737407..632523c 100644
@@ -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;