OSDN Git Service

clocksource: Prevent double add_timer_on() for watchdog_timer
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / kernel / time / clocksource.c
index b98810d..a20368e 100644 (file)
@@ -272,8 +272,15 @@ static void clocksource_watchdog(unsigned long data)
        next_cpu = cpumask_next(raw_smp_processor_id(), cpu_online_mask);
        if (next_cpu >= nr_cpu_ids)
                next_cpu = cpumask_first(cpu_online_mask);
-       watchdog_timer.expires += WATCHDOG_INTERVAL;
-       add_timer_on(&watchdog_timer, next_cpu);
+
+       /*
+        * Arm timer if not already pending: could race with concurrent
+        * pair clocksource_stop_watchdog() clocksource_start_watchdog().
+        */
+       if (!timer_pending(&watchdog_timer)) {
+               watchdog_timer.expires += WATCHDOG_INTERVAL;
+               add_timer_on(&watchdog_timer, next_cpu);
+       }
 out:
        spin_unlock(&watchdog_lock);
 }