Skip to contentSkip to conversation

clocksource/drivers/stm: Fix double deregistration on probe failure

PATCH Applied Johan Hovold 3 participants 3 messages Oct 17, 2025 – Nov 26, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource/drivers/stm: Fix double deregistration on probe failure

The purpose of the devm_add_action_or_reset() helper is to call the action function in case adding an action ever fails so drop the clock source deregistration from the error path to avoid deregistering twice.

Fixes cec32ac75827 ("clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms")
Cc Daniel Lezcano <[email protected]>
---
 drivers/clocksource/timer-nxp-stm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clocksource/timer-nxp-stm.c +1 -3
index ce10bdcfc76b..c320d764b12e 100644
@@ -208,10 +208,8 @@ static int nxp_stm_clocksource_init(struct device *dev, struct stm_timer *stm_ti
 		return ret;
 
 	ret = devm_add_action_or_reset(dev, devm_clocksource_unregister, stm_timer);
-	if (ret) {
-		clocksource_unregister(&stm_timer->cs);
+	if (ret)
 		return ret;
-	}
 
 	stm_sched_clock = stm_timer;
 
Signature · 1 line
2.49.1
#1 lore raw
Quoted 8 lines · Johan Hovold

The purpose of the devm_add_action_or_reset() helper is to call the action function in case adding an action ever fails so drop the clock source deregistration from the error path to avoid deregistering twice.

Fixes cec32ac75827 ("clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms")
Cc Daniel Lezcano <[email protected]>

---

Ah, right. Good catch, thanks for fixing this

I picked it up

-- Daniel

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
merge bot Applied
#2 lore raw
In reply to Johan Hovold
The following commit has been merged into the timers/clocksource branch of tip:

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

Commit-ID:     6b38a8b31e2c5c2c3fd5f9848850788c190f216d
Gitweb:        https://git.kernel.org/tip/6b38a8b31e2c5c2c3fd5f9848850788c190f216d
Author:        Johan Hovold <[email protected]>
AuthorDate:    Fri, 17 Oct 2025 07:50:39 +02:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Wed, 26 Nov 2025 11:24:37 +01:00

clocksource/drivers/stm: Fix double deregistration on probe failure

The purpose of the devm_add_action_or_reset() helper is to call the action function in case adding an action ever fails so drop the clock source deregistration from the error path to avoid deregistering twice.

Fixes cec32ac75827 ("clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms")
Cc Daniel Lezcano <[email protected]>
---
 drivers/clocksource/timer-nxp-stm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clocksource/timer-nxp-stm.c +1 -3
index bbc4062..16d5216 100644
@@ -208,10 +208,8 @@ static int __init nxp_stm_clocksource_init(struct device *dev, struct stm_timer 
 		return ret;
 
 	ret = devm_add_action_or_reset(dev, devm_clocksource_unregister, stm_timer);
-	if (ret) {
-		clocksource_unregister(&stm_timer->cs);
+	if (ret)
 		return ret;
-	}
 
 	stm_sched_clock = stm_timer;