Documentation/watchdog: close the fd when cmdline arg given
Subsystems (2)
PATCH 1/1 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.
--- Documentation/watchdog/src/watchdog-test.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Documentation/watchdog/src/watchdog-test.c +6 -3
@@ -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 ; }
Signature · 1 line
1.7.9.5
Hi Devendra,
Quoted 4 lines
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 <[email protected]>
Patch added to linux-watchdog-next.
Kind regards,
Wim.
Hello Wim,
Quoted 5 lines · Wim Van Sebroeck
Hi Devendra,
Quoted 3 lines
in the watchdog test code, the ioctl is performed on the watchdog device and just doing exit(0) so we leak a filedescripor.
Quoted 7 lines
Quoted 1 line
Signed-off-by Devendra Naga <[email protected]>Patch added to linux-watchdog-next.
Kind regards,
Wim.
Thanks for taking the patch.
Actually we have a while (1) loop when ever user does ./watchdog-test, and if ctrl + c is done, we wont close the socket.
i will send the patch sooner to fix this on top this patch.
Thanks,
Devendra.