]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
timecompare: fix half-Y2K38 problem in timecompare_update while calculating offset
authorBarry Song <21cnbao@gmail.com>
Wed, 16 Dec 2009 00:45:34 +0000 (16:45 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2009 15:19:57 +0000 (07:19 -0800)
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>
kernel/time/timecompare.c

index 96ff643a5a59bdf1745e776434115cd430fa3935..12f5c55090bea159652c299d0db1a0a2969a3424 100644 (file)
@@ -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 */