From patchwork Wed Jun 1 18:53:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 69057 Delivered-To: patches@linaro.org Received: by 10.140.92.199 with SMTP id b65csp255119qge; Wed, 1 Jun 2016 11:53:34 -0700 (PDT) X-Received: by 10.98.1.132 with SMTP id 126mr11593430pfb.27.1464807213988; Wed, 01 Jun 2016 11:53:33 -0700 (PDT) Return-Path: Received: from mail-pf0-x230.google.com (mail-pf0-x230.google.com. [2607:f8b0:400e:c00::230]) by mx.google.com with ESMTPS id o14si52608581pfj.121.2016.06.01.11.53.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jun 2016 11:53:33 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::230 as permitted sender) client-ip=2607:f8b0:400e:c00::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::230 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x230.google.com with SMTP id b124so20250963pfb.0 for ; Wed, 01 Jun 2016 11:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y4pFn+ynVufT9ntJg4/PW7/rcv5rcEQBVUXE8rhjy1Y=; b=PsH0tB4IHA5sFE2xuAl0/IFlFFDV0VmBe5Vg3ZN40yAmG8LnBjSVcGw9Tyhnpf+Wgf SZdbRR+p2Jr/s23EBGPL7m4Kk3W4RwnSnYWX5jiNRFgC5B0zbacGswPVZ+0rRIlFZ9Je 3Iz4IwURQBgj7wY64d+xZ4mA5arcXHv+2Luhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Y4pFn+ynVufT9ntJg4/PW7/rcv5rcEQBVUXE8rhjy1Y=; b=iZZknTfQMOTCBYMcRJYzbE4dm+aTNPBkUzEj8GNJvfOnl0W06XS0q+RcyyG4OfkSyD TK8969aeTtSLw1avylkbYbEcSvEV3dKyzKeHeLR51MFJs51Ugyy+5gs94gLUu6fYYNh1 YxXGyILlzcXQHnT9ugT5gUesnWt11J02xbmpxA+TeYcZgpiTmcCELman2GLxsTPaAQMF txx3X7SS16+pPsuTeN+axO9qCs7vtmNw9orvty4FPDfxJXidvAm1YFaHLThTOnQych/7 5MdndmWyZZ0grdLtZbdFyDU7IERe3pFCZnMC9IJ8wJuHE2jOMx80zl3jTwKrBXOaJCfU DiBA== X-Gm-Message-State: ALyK8tK3NGQPfeOmZ1s5WUKCJKCR8HaTNnt94jDl2ZmmfofSYbHNGrwxRbfaynxysHagcduaZL8= X-Received: by 10.98.103.86 with SMTP id b83mr11572294pfc.141.1464807213691; Wed, 01 Jun 2016 11:53:33 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-73-67-244-238.hsd1.or.comcast.net. [73.67.244.238]) by smtp.gmail.com with ESMTPSA id t77sm49839932pfa.71.2016.06.01.11.53.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 11:53:33 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Mika Westerberg , Baolin Wang , Thomas Gleixner , Shuah Khan , Arnd Bergmann , Ingo Molnar , Richard Cochran , Prarit Bhargava Subject: [PATCH 1/2 v2] time: Fix problematic change in settimeofday error checking Date: Wed, 1 Jun 2016 11:53:26 -0700 Message-Id: <1464807207-16530-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464807207-16530-1-git-send-email-john.stultz@linaro.org> References: <1464807207-16530-1-git-send-email-john.stultz@linaro.org> In commit 86d3473224b0 ("time: Introduce do_sys_settimeofday64()") some of the checking for a valid timeval was subtley changed which caused -EINVAL to be returned whenever the timeval was null. However, it is possible to set the timezone data while specifying a NULL timeval, which is usually done to handle systems where the RTC keeps local time instead of UTC. Thus the patch causes such systems to have the time incorrectly set. This patch addresses the issue by handling the error conditionals in the same way as was done previously. Cc: Mika Westerberg Cc: Baolin Wang Cc: Thomas Gleixner Cc: Shuah Khan Cc: Arnd Bergmann Cc: Ingo Molnar Cc: Richard Cochran Cc: Prarit Bhargava Tested-by: Mika Westerberg Reported-by: Mika Westerberg Signed-off-by: John Stultz --- v2: Add logic simplification from Dima Stepanov include/linux/timekeeping.h | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.1 diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 37dbacf..816b754 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -21,6 +21,9 @@ static inline int do_sys_settimeofday(const struct timespec *tv, struct timespec64 ts64; if (!tv) + return do_sys_settimeofday64(NULL, tz); + + if (!timespec_valid(tv)) return -EINVAL; ts64 = timespec_to_timespec64(*tv);