]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - kernel/time/alarmtimer.c
alarmtimer: Unregister wakeup source when module get fails
[mirror_ubuntu-bionic-kernel.git] / kernel / time / alarmtimer.c
index f4255a65c44b2347bd4559137e53c2bf7636cd0c..9eece67f29f3410da76fef0ced327237e6147d3e 100644 (file)
@@ -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;
        }
+unlock:
        spin_unlock_irqrestore(&rtcdev_lock, flags);
 
        wakeup_source_unregister(__ws);
 
-       return 0;
+       return ret;
 }
 
 static inline void alarmtimer_rtc_timer_init(void)