From: Devendra Naga Date: Mon, 14 May 2012 18:12:02 +0000 (+0530) Subject: Documentation/watchdog: close the fd when cmdline arg given X-Git-Tag: v3.5-rc1~113^2~1 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=3c2a6186c1a69d647e3a48ad3f7f9078c451111e;p=linux.git Documentation/watchdog: close the fd when cmdline arg given in the watchdog test code, the ioctl is performed on the watchdog device and just doing exit(0) so we leak a filedescripor. Signed-off-by: Devendra Naga Signed-off-by: Wim Van Sebroeck --- diff --git a/Documentation/watchdog/src/watchdog-test.c b/Documentation/watchdog/src/watchdog-test.c index 63fdc34ceb98..23084f221279 100644 --- a/Documentation/watchdog/src/watchdog-test.c +++ b/Documentation/watchdog/src/watchdog-test.c @@ -47,18 +47,18 @@ int main(int argc, char *argv[]) ioctl(fd, WDIOC_SETOPTIONS, &flags); fprintf(stderr, "Watchdog card disabled.\n"); fflush(stderr); - exit(0); + goto end; } else if (!strncasecmp(argv[1], "-e", 2)) { flags = WDIOS_ENABLECARD; ioctl(fd, WDIOC_SETOPTIONS, &flags); fprintf(stderr, "Watchdog card enabled.\n"); fflush(stderr); - exit(0); + goto end; } else { fprintf(stderr, "-d to disable, -e to enable.\n"); fprintf(stderr, "run by itself to tick the card.\n"); fflush(stderr); - exit(0); + goto end; } } else { fprintf(stderr, "Watchdog Ticking Away!\n"); @@ -69,4 +69,7 @@ int main(int argc, char *argv[]) keep_alive(); sleep(1); } +end: + close(fd); + return 0; }