From patchwork Tue May 31 21:32:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 68954 Delivered-To: patches@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2194827qge; Tue, 31 May 2016 14:32:21 -0700 (PDT) X-Received: by 10.98.92.133 with SMTP id q127mr394954pfb.103.1464730341097; Tue, 31 May 2016 14:32:21 -0700 (PDT) Return-Path: Received: from mail-pf0-x22b.google.com (mail-pf0-x22b.google.com. [2607:f8b0:400e:c00::22b]) by mx.google.com with ESMTPS id ie10si6573759pad.48.2016.05.31.14.32.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 May 2016 14:32:21 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22b as permitted sender) client-ip=2607:f8b0:400e:c00::22b; 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::22b as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x22b.google.com with SMTP id 62so274354pfd.1 for ; Tue, 31 May 2016 14:32:20 -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=yp+H83RcP00iESxPZloXYS2wsFTYt8ZKE7efoDQ1/cM=; b=hd/tlvKMoRI5Fi7OOBbYK5sk2FaqQ8a2tGCWIMn8q7PKAtJnqs3zylthHOKSrP1yog MGWQitUWiCWIvOWJUvgUjH2n+PYhXS6D6BOYoUdIIUKjMuCZkMXYvg6pcEDyzqet4tky VvUfSFkYxVGppS3vSH3S9+O5H3igPRxPfhLOk= 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=yp+H83RcP00iESxPZloXYS2wsFTYt8ZKE7efoDQ1/cM=; b=Y1tjNzBtb1itOS/8dwLQDe1Pzi7ZJo+i9kzKATdYB1rcqPodNISV8PSCDSzKLIofPm PEgWE5ztFv4cu9wFl4EvCzu5dMfRxA7oIKqUjucdcdiP80+sNfSuVXF09Vs4qfVC1UX5 dBQ1MLWetkuPaJha3GuANz2R69Ha1a7SO0JCUO1LwyQVGAXCj5UiyJhIQQrQeDzV0ro9 W8xhqWKWH3WY4UWeMAQhjfJD3u1b48viU/j9fdD/x+m+OwLeZiRLjeGrhXdpTeL4FzRX iSEaIu2+9r+QQ5wY0+hbOtr1E+Scx75OzKJxu0bGU/h0zNAt0rt/pCSQdCmCm/f2u0tR dmWQ== X-Gm-Message-State: ALyK8tLIIA+0HiJd21hOlm4Xj92b3REscWH7R2LIIrXpfC16hABCZHMffwvJlLJJgWZIN8LEiQw= X-Received: by 10.98.94.135 with SMTP id s129mr419322pfb.43.1464730340689; Tue, 31 May 2016 14:32:20 -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 83sm42535207pfl.12.2016.05.31.14.32.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 May 2016 14:32:20 -0700 (PDT) From: John Stultz To: linux-kernel@vger.kernel.org Cc: John Stultz , Mika Westerberg , Baolin Wang , Thomas Gleixner , Shuah Khan , Arnd Bergmann , Ingo Molnar , Richard Cochran , Prarit Bhargava Subject: [RFC][PATCH 1/2] time: Fix problematic change in settimeofday error checking Date: Tue, 31 May 2016 14:32:14 -0700 Message-Id: <1464730335-21427-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464730335-21427-1-git-send-email-john.stultz@linaro.org> References: <1464730335-21427-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 Reported-by: Mika Westerberg Signed-off-by: John Stultz --- 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..4f01607 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 (tv && !timespec_valid(tv)) return -EINVAL; ts64 = timespec_to_timespec64(*tv);