Commit 7f4d7e8f authored by Colin Cross's avatar Colin Cross Committed by Ben Hutchings

timekeeping: fix 32-bit overflow in get_monotonic_boottime

fixed upstream in v3.6 by ec145bab

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: default avatarColin Cross <ccross@android.com>
[jstultz: Fished this out of the AOSP commong.git tree. This was
fixed upstream in v3.6 by ec145bab]
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 5162fef0
...@@ -1161,7 +1161,7 @@ void get_monotonic_boottime(struct timespec *ts) ...@@ -1161,7 +1161,7 @@ void get_monotonic_boottime(struct timespec *ts)
} while (read_seqretry(&xtime_lock, seq)); } while (read_seqretry(&xtime_lock, seq));
set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec, 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); EXPORT_SYMBOL_GPL(get_monotonic_boottime);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment