Skip to content

Commit

Permalink
timecompare: fix half-Y2K38 problem in timecompare_update while calcu…
Browse files Browse the repository at this point in the history
…lating offset

ktime will overflow from 03:14:07 UTC on Tuesday, 19 January 2038,
ktime_add() in timecompare_update() will overflow a half earlier.  As a
result, wrong offset will be gotten, then cause some strange problems.

Signed-off-by: Barry Song <21cnbao@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Patrick Ohly <patrick.ohly@intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Barry Song authored and Linus Torvalds committed Dec 16, 2009
1 parent 4365a56 commit f065f41
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/time/timecompare.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int timecompare_offset(struct timecompare *sync,
* source time
*/
sample.offset =
ktime_to_ns(ktime_add(end, start)) / 2 -
(ktime_to_ns(end) + ktime_to_ns(start)) / 2 -
ts;

/* simple insertion sort based on duration */
Expand Down

0 comments on commit f065f41

Please sign in to comment.