diff mbox

[U-Boot,v5,08/11] rtc: Don't allow setting unsuported years on s3c24x0_rtc

Message ID 1348253268-21812-9-git-send-email-jose.goncalves@inov.pt
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Commit Message

José Miguel Gonçalves Sept. 21, 2012, 6:47 p.m. UTC
This RTC only supports a 100 years range so rtc_set() should not allow setting
years bellow 1970 or above 2069.

Signed-off-by: José Miguel Gonçalves <jose.goncalves@inov.pt>
---
Changes for v2:
   - New patch

Changes for v3:
   - None

Changes for v4:
   - None

Changes for v5:
   - None
---
 drivers/rtc/s3c24x0_rtc.c |    5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/drivers/rtc/s3c24x0_rtc.c b/drivers/rtc/s3c24x0_rtc.c
index 3fd5cec..bcd6d44 100644
--- a/drivers/rtc/s3c24x0_rtc.c
+++ b/drivers/rtc/s3c24x0_rtc.c
@@ -139,6 +139,11 @@  int rtc_set(struct rtc_time *tmp)
 	       tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
 	       tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
 #endif
+	if (tmp->tm_year < 1970 || tmp->tm_year > 2069) {
+		puts("ERROR: year should be between 1970 and 2069!\n");
+		return -1;
+	}
+
 	year = bin2bcd(tmp->tm_year % 100);
 	mon  = bin2bcd(tmp->tm_mon);
 	wday = bin2bcd(tmp->tm_wday);