Vaibhav Jain da96aea0ed rtc: interface: Validate alarm-time before handling rollover
In function __rtc_read_alarm() its possible for an alarm time-stamp to
be invalid even after replacing missing components with current
time-stamp. The condition 'alarm->time.tm_year < 70' will trigger this
case and will cause the call to 'rtc_tm_to_time64(&alarm->time)'
return a negative value for variable t_alm.

While handling alarm rollover this negative t_alm (assumed to seconds
offset from '1970-01-01 00:00:00') is converted back to rtc_time via
rtc_time64_to_tm() which results in this error log with seemingly
garbage values:

"rtc rtc0: invalid alarm value: -2-1--1041528741
2005511117:71582844:32"

This error was generated when the rtc driver (rtc-opal in this case)
returned an alarm time-stamp of '00-00-00 00:00:00' to indicate that
the alarm is disabled. Though I have submitted a separate fix for the
rtc-opal driver, this issue may potentially impact other
existing/future rtc drivers.

To fix this issue the patch validates the alarm time-stamp just after
filling up the missing datetime components and if rtc_valid_tm() still
reports it to be invalid then bails out of the function without
handling the rollover.

Reported-by: Steve Best <sbest@redhat.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-05-31 13:04:54 +02:00
..
2017-05-10 09:35:42 -07:00
2017-05-09 10:01:15 -07:00
2017-05-09 15:40:28 -07:00
2017-05-09 10:01:15 -07:00
2017-05-04 19:15:35 -07:00
2017-04-30 11:45:31 -07:00
2017-05-09 15:15:47 -07:00
2017-05-05 19:33:07 -07:00
2017-05-11 10:44:22 -07:00
2017-04-27 11:54:49 +01:00
2017-05-12 10:04:09 -07:00
2017-04-20 09:54:24 +02:00
2017-05-09 10:01:15 -07:00
2017-05-12 10:04:09 -07:00
2017-05-04 19:15:35 -07:00
2017-05-04 19:15:35 -07:00
2017-05-09 10:01:15 -07:00
2017-05-10 11:33:08 -07:00
2017-05-12 10:04:09 -07:00
2017-05-05 19:33:07 -07:00
2017-05-05 11:36:44 -07:00
2017-05-11 11:12:26 -07:00