From: Barry Song <21cnbao@gmail.com> Date: Wed, 16 Dec 2009 00:45:34 +0000 (-0800) Subject: timecompare: fix half-Y2K38 problem in timecompare_update while calculating offset X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=f065f41f48569122b5bcddbd1ba2354f7cc29fdc;p=linux-edison.git timecompare: fix half-Y2K38 problem in timecompare_update while calculating 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 Cc: Ingo Molnar Cc: Patrick Ohly Cc: David S. Miller Cc: John Stultz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/time/timecompare.c b/kernel/time/timecompare.c index 96ff643a5a5..12f5c55090b 100644 --- a/kernel/time/timecompare.c +++ b/kernel/time/timecompare.c @@ -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 */