mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
rtc: rtc-isl1208: reject invalid dates
This patch for the rtc-isl1208 driver makes it reject invalid dates. Signed-off-by: Chris Elston <celston@katalix.com> [a.zummo@towertech.it: added comment explaining the check] Signed-off-by: Alessandro Zummo <a.zummo@towertech.it> Cc: Hebert Valerio Riedel <hvr@gnu.org> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c47a75a45f
commit
cc6c2ca300
1 changed files with 7 additions and 0 deletions
|
@ -328,6 +328,13 @@ isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm)
|
||||||
int sr;
|
int sr;
|
||||||
u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
|
u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, };
|
||||||
|
|
||||||
|
/* The clock has an 8 bit wide bcd-coded register (they never learn)
|
||||||
|
* for the year. tm_year is an offset from 1900 and we are interested
|
||||||
|
* in the 2000-2099 range, so any value less than 100 is invalid.
|
||||||
|
*/
|
||||||
|
if (tm->tm_year < 100)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec);
|
regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec);
|
||||||
regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min);
|
regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min);
|
||||||
regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL;
|
regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL;
|
||||||
|
|
Loading…
Reference in a new issue