[patch-rt 2/5] commit 6626bff24578753808c8b5bd4f1619e14e980f0fAuthor: Thomas Gleixner <tglx@linutronix.de> Date: Sun Jan 2511:31:36 2009 +0100

From: Thomas Gleixner
Date: Fri Jan 30 2009 - 06:44:27 EST


hrtimer: prevent negative expiry value after clock_was_set()

Impact: prevent false positive WARN_ON() in clockevents_program_event()

clock_was_set() changes the base->offset of CLOCK_REALTIME and
enforces the reprogramming of the clockevent device to expire timers
which are based on CLOCK_REALTIME. If the clock change is large enough
then the subtraction of the timer expiry value and base->offset can
become negative which triggers the warning in
clockevents_program_event().

Check the subtraction result and set a negative value to 0.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

---
kernel/hrtimer.c | 7 +++++++
1 file changed, 7 insertions(+)

Index: linux-2.6.26.8/kernel/hrtimer.c
===================================================================
--- linux-2.6.26.8.orig/kernel/hrtimer.c
+++ linux-2.6.26.8/kernel/hrtimer.c
@@ -520,6 +520,13 @@ static void hrtimer_force_reprogram(stru
continue;
timer = rb_entry(base->first, struct hrtimer, node);
expires = ktime_sub(timer->expires, base->offset);
+ /*
+ * clock_was_set() has changed base->offset so the
+ * result might be negative. Fix it up to prevent a
+ * false positive in clockevents_program_event()
+ */
+ if (expires.tv64 < 0)
+ expires.tv64 = 0;
if (expires.tv64 < cpu_base->expires_next.tv64)
cpu_base->expires_next = expires;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/