Skip to content

Commit a6d6e1c

Browse files
Xunlei Pangjohnstultz-work
authored andcommitted
rtc: Modify rtc_hctosys() to address y2038 issues
rtc_hctosys() has a number of y2038 issues. This patch resolves them by: - Replace rtc_tm_to_time() with y2038-safe rtc_tm_to_time64() - Replace do_settimeofday() with y2038-safe do_settimeofday64() After this patch, it should not have any remaining y2038 issues. Cc: pang.xunlei <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Signed-off-by: Xunlei Pang <[email protected]> Signed-off-by: John Stultz <[email protected]>
1 parent 4ec2364 commit a6d6e1c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/rtc/hctosys.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int __init rtc_hctosys(void)
2626
{
2727
int err = -ENODEV;
2828
struct rtc_time tm;
29-
struct timespec tv = {
29+
struct timespec64 tv64 = {
3030
.tv_nsec = NSEC_PER_SEC >> 1,
3131
};
3232
struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
@@ -52,16 +52,16 @@ static int __init rtc_hctosys(void)
5252
goto err_invalid;
5353
}
5454

55-
rtc_tm_to_time(&tm, &tv.tv_sec);
55+
tv64.tv_sec = rtc_tm_to_time64(&tm);
5656

57-
err = do_settimeofday(&tv);
57+
err = do_settimeofday64(&tv64);
5858

5959
dev_info(rtc->dev.parent,
6060
"setting system clock to "
61-
"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
61+
"%d-%02d-%02d %02d:%02d:%02d UTC (%lld)\n",
6262
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
6363
tm.tm_hour, tm.tm_min, tm.tm_sec,
64-
(unsigned int) tv.tv_sec);
64+
(long long) tv64.tv_sec);
6565

6666
err_invalid:
6767
err_read:

0 commit comments

Comments
 (0)