Linux RTC
 help / color / mirror / Atom feed
From: Einar Jon Gunnarsson <tolvupostur@gmail.com>
To: linux-rtc@vger.kernel.org
Cc: smuckle@google.com, Einar Jon Gunnarsson <tolvupostur@gmail.com>
Subject: [PATCH] rtc: class: Fix max epoch in rtc_hctosys on 32-bit systems
Date: Tue, 18 Feb 2025 11:11:50 +0000	[thread overview]
Message-ID: <20250218111150.3024-1-tolvupostur@gmail.com> (raw)

The check for BITS_PER_LONG == 32 makes no sense after calling
tv64.tv_sec = rtc_tm_to_time64(&tm);

With this check, any 32-bit system will silently return an -ERANGE error
instead of setting the correct time if the hardware clock is storing a
date after Y2K38 (2038-01-19).
Without this check they should all work as intended, since the rest of
the function is perfectly 64-bit safe.

Fixes: f9b2a4d6a5f1 ("rtc: class: support hctosys from modular RTC drivers")

Signed-off-by: Einar Jon Gunnarsson <tolvupostur@gmail.com>
---
 drivers/rtc/class.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index e31fa0ad127e..df58edf99ed3 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -72,13 +72,6 @@ static void rtc_hctosys(struct rtc_device *rtc)
 
 	tv64.tv_sec = rtc_tm_to_time64(&tm);
 
-#if BITS_PER_LONG == 32
-	if (tv64.tv_sec > INT_MAX) {
-		err = -ERANGE;
-		goto err_read;
-	}
-#endif
-
 	err = do_settimeofday64(&tv64);
 
 	dev_info(rtc->dev.parent, "setting system clock to %ptR UTC (%lld)\n",
-- 
2.34.1


             reply	other threads:[~2025-02-18 11:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18 11:11 Einar Jon Gunnarsson [this message]
     [not found] ` <CABhNV21ZptxH9d4NyPo1xivS0GAXNsoLMLpPSRAsT8h5CX9hDw@mail.gmail.com>
2025-02-18 13:28   ` [PATCH] rtc: class: Fix max epoch in rtc_hctosys on 32-bit systems Einar Jón
2025-02-18 13:30   ` Alexandre Belloni
2025-02-18 14:51     ` Arnd Bergmann
2025-02-18 15:40       ` Alexandre Belloni
2025-02-18 16:00         ` Einar Jón
2025-02-18 16:05         ` Arnd Bergmann
2025-02-18 16:39           ` Alexandre Belloni
2025-02-19  7:36             ` Einar Jón

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=20250218111150.3024-1-tolvupostur@gmail.com \
    --to=tolvupostur@gmail.com \
    --cc=linux-rtc@vger.kernel.org \
    --cc=smuckle@google.com \
    /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