All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: class: Fix max epoch in rtc_hctosys on 32-bit systems
@ 2025-02-18 11:11 Einar Jon Gunnarsson
       [not found] ` <CABhNV21ZptxH9d4NyPo1xivS0GAXNsoLMLpPSRAsT8h5CX9hDw@mail.gmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Einar Jon Gunnarsson @ 2025-02-18 11:11 UTC (permalink / raw)
  To: linux-rtc; +Cc: smuckle, Einar Jon Gunnarsson

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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-02-19  7:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-18 11:11 [PATCH] rtc: class: Fix max epoch in rtc_hctosys on 32-bit systems Einar Jon Gunnarsson
     [not found] ` <CABhNV21ZptxH9d4NyPo1xivS0GAXNsoLMLpPSRAsT8h5CX9hDw@mail.gmail.com>
2025-02-18 13:28   ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.