time: Fix sign bug in NTP mult overflow warning
authorJohn Stultz <john.stultz@linaro.org>
Tue, 25 Nov 2014 04:35:45 +0000 (20:35 -0800)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Nov 2014 06:18:34 +0000 (07:18 +0100)
In commit 6067dc5a8c2b ("time: Avoid possible NTP adjustment
mult overflow") a new check was added to watch for adjustments
that could cause a mult overflow.

Unfortunately the check compares a signed with unsigned value
and ignored the case where the adjustment was negative, which
causes spurious warn-ons on some systems (and seems like it
would result in problematic time adjustments there as well, due
to the early return).

Thus this patch adds a check to make sure the adjustment is
positive before we check for an overflow, and resovles the issue
in my testing.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Debugged-by: pang.xunlei <pang.xunlei@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/1416890145-30048-1-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/time/timekeeping.c

index 29a7d6709da18d07ade60dfc8a0cf1e63aca670f..2dc0646258aeebd1102cde4db5bd20162f4d5a4e 100644 (file)
@@ -1330,7 +1330,7 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk,
         *
         * XXX - TODO: Doc ntp_error calculation.
         */
-       if (tk->tkr.mult + mult_adj < mult_adj) {
+       if ((mult_adj > 0) && (tk->tkr.mult + mult_adj < mult_adj)) {
                /* NTP adjustment caused clocksource mult overflow */
                WARN_ON_ONCE(1);
                return;