Message ID | 20180117153048.17727-1-sz.lin@moxa.com |
---|---|
State | Superseded |
Headers | show |
Series | rtc: tps65910: add bounds checking | expand |
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c index d0244d7979fc..6be9f7bb0f1b 100644 --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c @@ -105,6 +105,12 @@ static int tps65910_rtc_set_time(struct device *dev, struct rtc_time *tm) struct tps65910 *tps = dev_get_drvdata(dev->parent); int ret; + if ((tm->tm_year - 100) < 0) { + dev_err(dev, "the requested year %d is unsupported\n", + 1900 + tm->tm_year); + return -EINVAL; + } + rtc_data[0] = bin2bcd(tm->tm_sec); rtc_data[1] = bin2bcd(tm->tm_min); rtc_data[2] = bin2bcd(tm->tm_hour);