From: Colin Cross Date: Wed, 26 Sep 2012 21:21:22 +0000 (-0700) Subject: timekeeping: fix 32-bit overflow in get_monotonic_boottime X-Git-Tag: firefly_0821_release~8486 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d21898f6906195730532b4fb99eab3d2a61089a6;p=firefly-linux-kernel-4.4.55.git timekeeping: fix 32-bit overflow in get_monotonic_boottime 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. Change-Id: Ic996d8b6fbef0b72f2d027b0d8ef5259b5c1a540 Signed-off-by: Colin Cross --- diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 84d4f8b25f32..5f00308a4e9b 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1027,7 +1027,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);