Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752051AbaKYEgC (ORCPT ); Mon, 24 Nov 2014 23:36:02 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:55522 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbaKYEgA (ORCPT ); Mon, 24 Nov 2014 23:36:00 -0500 From: John Stultz To: lkml Cc: John Stultz , "pang.xunlei" , Fengguang Wu , Thomas Gleixner , Ingo Molnar Subject: [PATCH] time: Fix sign bug in ntp mult overflow warning Date: Mon, 24 Nov 2014 20:35:45 -0800 Message-Id: <1416890145-30048-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20141122184506.GC29361@wfg-t540p.sh.intel.com> References: <20141122184506.GC29361@wfg-t540p.sh.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: pang.xunlei Cc: Fengguang Wu Cc: Thomas Gleixner Cc: Ingo Molnar Reported-by: Fengguang Wu Debugged-by: pang.xunlei Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 29a7d67..2dc0646 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -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; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/