From f3010c6a8e7946bfb8db9a681e7bff6d93e56a7c Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 5 Aug 2021 09:22:14 -0400 Subject: hosted: Fix rtc_write_datetime() error handling (if mktime() fails, don't attempt to write its result to the RTC) Change-Id: Ib09b8dccafdef032119db76f10af74dfc220cc21 --- firmware/target/hosted/rtc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'firmware/target/hosted/rtc.c') diff --git a/firmware/target/hosted/rtc.c b/firmware/target/hosted/rtc.c index e747aece38..05c8f75ef7 100644 --- a/firmware/target/hosted/rtc.c +++ b/firmware/target/hosted/rtc.c @@ -54,6 +54,9 @@ int rtc_write_datetime(const struct tm *tm) tv.tv_sec = mktime((struct tm *)tm); tv.tv_usec = 0; + if ((int)tv.tv_sec == -1) + return -1; + /* set system clock */ settimeofday(&tv, NULL); -- cgit v1.2.3