summaryrefslogtreecommitdiffstats
path: root/commands/hwclock.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2016-01-06 22:17:35 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2016-01-07 08:47:25 +0100
commit4c9b2e72057ca3d1578b33ff75ad251bb8225a9c (patch)
treebfd60d16573c865611358813cde7340dfc0916e2 /commands/hwclock.c
parent645320b94aaa0f478d31809673df6f83964c5292 (diff)
downloadbarebox-4c9b2e72057ca3d1578b33ff75ad251bb8225a9c.tar.gz
commands/hwclock: Check return value of rtc_read_time()
It is possible for rtc_read_time() to fill struct rtc_time it returns with invalid values, so we have to check for its return value before using returned time. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/hwclock.c')
-rw-r--r--commands/hwclock.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/commands/hwclock.c b/commands/hwclock.c
index 7633132..6a0fe03 100644
--- a/commands/hwclock.c
+++ b/commands/hwclock.c
@@ -93,11 +93,11 @@ static int do_hwclock(int argc, char *argv[])
char *env_name = NULL;
int opt;
int set = 0;
+ int ret;
int ntp_to_hw = 0;
char *ntpserver = NULL;
while ((opt = getopt(argc, argv, "f:s:e:n:")) > 0) {
- int ret;
switch (opt) {
case 'f':
@@ -151,7 +151,9 @@ static int do_hwclock(int argc, char *argv[])
return rtc_set_time(r, &stm);
}
- rtc_read_time(r, &tm);
+ ret = rtc_read_time(r, &tm);
+ if (ret < 0)
+ return ret;
if (env_name) {
unsigned long time;