From: Colin Cross Date: Mon, 10 Feb 2014 21:16:29 +0000 (-0800) Subject: timekeeping: fix 32-bit overflow in get_monotonic_boottime X-Git-Tag: v3.2.56~17 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=commitdiff_plain;h=7f4d7e8fe42d3a34994055355694236f489c874f timekeeping: fix 32-bit overflow in get_monotonic_boottime fixed upstream in v3.6 by ec145babe754f9ea1079034a108104b6001e001c get_monotonic_boottime adds three nanonsecond values stored in longs, followed by an s64. If the long values are all close to 1e9 the first three additions can overflow and become negative when added to the s64. Cast the first value to s64 so that all additions are 64 bit. Signed-off-by: Colin Cross [jstultz: Fished this out of the AOSP commong.git tree. This was fixed upstream in v3.6 by ec145babe754f9ea1079034a108104b6001e001c] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index cb7f33e548b3..068c0929904c 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1161,7 +1161,7 @@ void get_monotonic_boottime(struct timespec *ts) } while (read_seqretry(&xtime_lock, seq)); set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec, - ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec + nsecs); + (s64)ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec + nsecs); } EXPORT_SYMBOL_GPL(get_monotonic_boottime);