Skip to content

Commit

Permalink
Documentation/watchdog: close the fd when cmdline arg given
Browse files Browse the repository at this point in the history
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 <devendra.aaru@gmail.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Devendra Naga authored and Wim Van Sebroeck committed May 23, 2012
1 parent 2deca73 commit 3c2a618
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Documentation/watchdog/src/watchdog-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -69,4 +69,7 @@ int main(int argc, char *argv[])
keep_alive();
sleep(1);
}
end:
close(fd);
return 0;
}

0 comments on commit 3c2a618

Please sign in to comment.