public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@linux-mips.org>
To: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] rtc: hctosys: Add missing range error reporting
Date: Mon, 5 Nov 2018 03:48:25 +0000 (GMT)	[thread overview]
Message-ID: <alpine.LFD.2.21.1811050319150.20378@eddie.linux-mips.org> (raw)

Fix an issue with the 32-bit range error path in `rtc_hctosys' where no 
error code is set and consequently the successful preceding call result 
from `rtc_read_time' is propagated to `rtc_hctosys_ret'.  This in turn 
makes any subsequent call to `hctosys_show' incorrectly report in sysfs 
that the system time has been set from this RTC while it has not.

Set the error to ERANGE then if we can't express the result due to an 
overflow.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: b3a5ac42ab18 ("rtc: hctosys: Ensure system time doesn't overflow time_t")
Cc: stable@vger.kernel.org # 4.17+
---
 drivers/rtc/hctosys.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

linux-rtc-hctosys-range.diff
Index: linux-20181008-swarm64-eb/drivers/rtc/hctosys.c
===================================================================
--- linux-20181008-swarm64-eb.orig/drivers/rtc/hctosys.c
+++ linux-20181008-swarm64-eb/drivers/rtc/hctosys.c
@@ -50,8 +50,10 @@ static int __init rtc_hctosys(void)
 	tv64.tv_sec = rtc_tm_to_time64(&tm);
 
 #if BITS_PER_LONG == 32
-	if (tv64.tv_sec > INT_MAX)
+	if (tv64.tv_sec > INT_MAX) {
+		err = -ERANGE;
 		goto err_read;
+	}
 #endif
 
 	err = do_settimeofday64(&tv64);

             reply	other threads:[~2018-11-05 13:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-05  3:48 Maciej W. Rozycki [this message]
2018-11-07 16:23 ` [PATCH] rtc: hctosys: Add missing range error reporting Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.21.1811050319150.20378@eddie.linux-mips.org \
    --to=macro@linux-mips.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox