Commit 3c2a6186 authored by Devendra Naga's avatar Devendra Naga Committed by Wim Van Sebroeck

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: default avatarDevendra Naga <devendra.aaru@gmail.com>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 2deca736
...@@ -47,18 +47,18 @@ int main(int argc, char *argv[]) ...@@ -47,18 +47,18 @@ int main(int argc, char *argv[])
ioctl(fd, WDIOC_SETOPTIONS, &flags); ioctl(fd, WDIOC_SETOPTIONS, &flags);
fprintf(stderr, "Watchdog card disabled.\n"); fprintf(stderr, "Watchdog card disabled.\n");
fflush(stderr); fflush(stderr);
exit(0); goto end;
} else if (!strncasecmp(argv[1], "-e", 2)) { } else if (!strncasecmp(argv[1], "-e", 2)) {
flags = WDIOS_ENABLECARD; flags = WDIOS_ENABLECARD;
ioctl(fd, WDIOC_SETOPTIONS, &flags); ioctl(fd, WDIOC_SETOPTIONS, &flags);
fprintf(stderr, "Watchdog card enabled.\n"); fprintf(stderr, "Watchdog card enabled.\n");
fflush(stderr); fflush(stderr);
exit(0); goto end;
} else { } else {
fprintf(stderr, "-d to disable, -e to enable.\n"); fprintf(stderr, "-d to disable, -e to enable.\n");
fprintf(stderr, "run by itself to tick the card.\n"); fprintf(stderr, "run by itself to tick the card.\n");
fflush(stderr); fflush(stderr);
exit(0); goto end;
} }
} else { } else {
fprintf(stderr, "Watchdog Ticking Away!\n"); fprintf(stderr, "Watchdog Ticking Away!\n");
...@@ -69,4 +69,7 @@ int main(int argc, char *argv[]) ...@@ -69,4 +69,7 @@ int main(int argc, char *argv[])
keep_alive(); keep_alive();
sleep(1); sleep(1);
} }
end:
close(fd);
return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment