Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rtc: check if __rtc_read_time was successful in rtc_timer_do_work()

If the __rtc_read_time call fails,, the struct rtc_time tm; may contain
uninitialized data, or an illegal date/time read from the RTC hardware.

When calling rtc_tm_to_ktime later, the result may be a very large value
(possibly KTIME_MAX). If there are periodic timers in rtc->timerqueue,
they will continually expire, may causing kernel softlockup.

Fixes: 6610e0893b8b ("RTC: Rework RTC code to use timerqueue for events")
Signed-off-by: Yongliang Gao <leonylgao@tencent.com>
Acked-by: Jingqun Li <jingqunli@tencent.com>
Link: https://lore.kernel.org/r/20241011043153.3788112-1-leonylgao@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Yongliang Gao and committed by
Alexandre Belloni
e8ba8a2b 00f1bb9b

+6 -1
+6 -1
drivers/rtc/interface.c
··· 904 904 struct timerqueue_node *next; 905 905 ktime_t now; 906 906 struct rtc_time tm; 907 + int err; 907 908 908 909 struct rtc_device *rtc = 909 910 container_of(work, struct rtc_device, irqwork); 910 911 911 912 mutex_lock(&rtc->ops_lock); 912 913 again: 913 - __rtc_read_time(rtc, &tm); 914 + err = __rtc_read_time(rtc, &tm); 915 + if (err) { 916 + mutex_unlock(&rtc->ops_lock); 917 + return; 918 + } 914 919 now = rtc_tm_to_ktime(tm); 915 920 while ((next = timerqueue_getnext(&rtc->timerqueue))) { 916 921 if (next->expires > now)