From patchwork Fri Sep 21 18:47:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [U-Boot, v5, 08/11] rtc: Don't allow setting unsuported years on s3c24x0_rtc Date: Fri, 21 Sep 2012 08:47:45 -0000 From: =?utf-8?q?Jos=C3=A9_Miguel_Gon=C3=A7alves?= X-Patchwork-Id: 185879 Message-Id: <1348253268-21812-9-git-send-email-jose.goncalves@inov.pt> To: u-boot@lists.denx.de Cc: marex@denx.de, trini@ti.com, =?UTF-8?q?Jos=C3=A9=20Miguel=20Gon=C3=A7alves?= , scottwood@freescale.com 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 --- 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 --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);