diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-01-25 05:31:36 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-30 16:35:34 -0500 |
commit | b0a9b5111abf60ef07eade834f480e89004c7920 (patch) | |
tree | a74aa7bacf920eb567cd7caa8027a06c96dbb220 | |
parent | 94df7de0289bc2df3d6e85cd2ece52bf42682f45 (diff) |
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@linutronix.de>
-rw-r--r-- | kernel/hrtimer.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 647a40e2fea1..f394d2a42ca3 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -501,6 +501,13 @@ static void hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base) | |||
501 | continue; | 501 | continue; |
502 | timer = rb_entry(base->first, struct hrtimer, node); | 502 | timer = rb_entry(base->first, struct hrtimer, node); |
503 | expires = ktime_sub(hrtimer_get_expires(timer), base->offset); | 503 | expires = ktime_sub(hrtimer_get_expires(timer), base->offset); |
504 | /* | ||
505 | * clock_was_set() has changed base->offset so the | ||
506 | * result might be negative. Fix it up to prevent a | ||
507 | * false positive in clockevents_program_event() | ||
508 | */ | ||
509 | if (expires.tv64 < 0) | ||
510 | expires.tv64 = 0; | ||
504 | if (expires.tv64 < cpu_base->expires_next.tv64) | 511 | if (expires.tv64 < cpu_base->expires_next.tv64) |
505 | cpu_base->expires_next = expires; | 512 | cpu_base->expires_next = expires; |
506 | } | 513 | } |