clockevents: warn once when program_event() is called with negative expiry
authorThomas Gleixner <tglx@linutronix.de>
Fri, 7 Dec 2007 18:16:17 +0000 (19:16 +0100)
committerIngo Molnar <mingo@elte.hu>
Fri, 7 Dec 2007 18:16:17 +0000 (19:16 +0100)
The hrtimer problem with large relative timeouts resulting in a
negative expiry time went unnoticed as there is no check in the
clockevents_program_event() code. Put a check there with a WARN_ONCE
to avoid such problems in the future.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/time/clockevents.c

index 822beebe664a59e98d3557c98a7ff8632423f6a1..5fb139fef9fa78821e0f85d640d211b1fbb0f5c7 100644 (file)
@@ -78,6 +78,11 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
        unsigned long long clc;
        int64_t delta;
 
+       if (unlikely(expires.tv64 < 0)) {
+               WARN_ON_ONCE(1);
+               return -ETIME;
+       }
+
        delta = ktime_to_ns(ktime_sub(expires, now));
 
        if (delta <= 0)