rtc: check if rtc_tm_to_ktime was successful in rtc_timer_do_work()

The struct rtc_time tm may contain a date/time read from the RTC hardware,
but it is far away from now. However, __rtc_read_time return success.

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

Signed-off-by: Yongliang Gao <leonylgao@tencent.com>
Reviewed-by: Jianping Liu <frankjpliu@tencent.com>
Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
This commit is contained in:
Yongliang Gao 2024-11-15 17:08:25 +08:00 committed by Jianping Liu
parent 083e3422ee
commit 6cf46c359c
1 changed files with 5 additions and 0 deletions

View File

@ -919,6 +919,11 @@ again:
return;
}
now = rtc_tm_to_ktime(tm);
if (now == KTIME_MAX) {
dev_err(&rtc->dev, "Failed to convert rtc time\n");
mutex_unlock(&rtc->ops_lock);
return;
}
while ((next = timerqueue_getnext(&rtc->timerqueue))) {
if (next->expires > now)
break;