only write to the watchdog if the fd is valid
authorJohn Crispin <blogic@openwrt.org>
Sun, 14 Dec 2014 21:12:45 +0000 (22:12 +0100)
committerJohn Crispin <blogic@openwrt.org>
Sun, 14 Dec 2014 21:28:55 +0000 (22:28 +0100)
Signed-off-by: John Crispin <blogic@openwrt.org>
watchdog.c

index 3c097e2..592ae7e 100644 (file)
@@ -35,7 +35,7 @@ static int wdt_frequency = 5;
 void watchdog_ping(void)
 {
        DEBUG(4, "Ping\n");
 void watchdog_ping(void)
 {
        DEBUG(4, "Ping\n");
-       if (write(wdt_fd, "X", 1) < 0)
+       if (wdt_fd >= 0 && write(wdt_fd, "X", 1) < 0)
                ERROR("WDT failed to write: %s\n", strerror(errno));
 }
 
                ERROR("WDT failed to write: %s\n", strerror(errno));
 }