Stable Archive on
 help / color / Atom feed
* [tip: timers/core] alarmtimer: Unregister wakeup source when module get fails
       [not found] <>
@ 2020-01-15 10:24 ` tip-bot2 for Stephen Boyd
  0 siblings, 0 replies; only message in thread
From: tip-bot2 for Stephen Boyd @ 2020-01-15 10:24 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Stephen Boyd, Thomas Gleixner, Douglas Anderson, stable, x86, LKML

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

Commit-ID:     6b6d188aae79a630957aefd88ff5c42af6553ee3
Author:        Stephen Boyd <>
AuthorDate:    Thu, 09 Jan 2020 07:59:07 -08:00
Committer:     Thomas Gleixner <>
CommitterDate: Wed, 15 Jan 2020 11:16:54 +01:00

alarmtimer: Unregister wakeup source when module get fails

The alarmtimer_rtc_add_device() function creates a wakeup source and then
tries to grab a module reference. If that fails the function returns early
with an error code, but fails to remove the wakeup source.

Cleanup this exit path so there is no dangling wakeup source, which is
named 'alarmtime' left allocated which will conflict with another RTC
device that may be registered later.

Fixes: 51218298a25e ("alarmtimer: Ensure RTC module is not unloaded")
Signed-off-by: Stephen Boyd <>
Signed-off-by: Thomas Gleixner <>
Reviewed-by: Douglas Anderson <>
 kernel/time/alarmtimer.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index b51b36e..9dc7a09 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -91,6 +91,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 	unsigned long flags;
 	struct rtc_device *rtc = to_rtc_device(dev);
 	struct wakeup_source *__ws;
+	int ret = 0;
 	if (rtcdev)
 		return -EBUSY;
@@ -105,8 +106,8 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 	spin_lock_irqsave(&rtcdev_lock, flags);
 	if (!rtcdev) {
 		if (!try_module_get(rtc->owner)) {
-			spin_unlock_irqrestore(&rtcdev_lock, flags);
-			return -1;
+			ret = -1;
+			goto unlock;
 		rtcdev = rtc;
@@ -115,11 +116,12 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 		ws = __ws;
 		__ws = NULL;
 	spin_unlock_irqrestore(&rtcdev_lock, flags);
-	return 0;
+	return ret;
 static inline void alarmtimer_rtc_timer_init(void)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <>
2020-01-15 10:24 ` [tip: timers/core] alarmtimer: Unregister wakeup source when module get fails tip-bot2 for Stephen Boyd

Stable Archive on

Archives are clonable:
	git clone --mirror stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ \
	public-inbox-index stable

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone