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 3c097e2273c55c34f90c251588aa0630a64f7299..592ae7e74f771472ef7a670f8badbac1084d4ed5 100644 (file)
@@ -35,7 +35,7 @@ static int wdt_frequency = 5;
 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));
 }