From: Andreas Schneider Date: Wed, 16 May 2018 09:46:22 +0000 (+0200) Subject: s4:torture: Do not leak file descriptor in smb2 oplock test X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=c83dad5b12cecfdd51fd573b62c0f1ed2b58855a s4:torture: Do not leak file descriptor in smb2 oplock test Found by Coverity. Signed-off-by: Andreas Schneider Reviewed-by: David Disseldorp Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Thu May 17 04:03:21 CEST 2018 on sn-devel-144 --- diff --git a/source4/torture/smb2/oplock.c b/source4/torture/smb2/oplock.c index 6e53007bcfc1..800a4cf299f2 100644 --- a/source4/torture/smb2/oplock.c +++ b/source4/torture/smb2/oplock.c @@ -4873,17 +4873,20 @@ static int do_child_process(int pipefd, const char *name) ret = fcntl(fd, F_SETSIG, RT_SIGNAL_LEASE); if (ret == -1) { + close(fd); return 3; } ret = fcntl(fd, F_SETLEASE, F_WRLCK); if (ret == -1) { + close(fd); return 4; } /* Tell the parent we're ready. */ ret = sys_write(pipefd, &c, 1); if (ret != 1) { + close(fd); return 5; } @@ -4893,14 +4896,17 @@ static int do_child_process(int pipefd, const char *name) /* Wait for RT_SIGNAL_LEASE or SIGALRM. */ ret = sigsuspend(&empty_set); if (ret != -1 || errno != EINTR) { + close(fd); return 6; } if (got_alarm == 1) { + close(fd); return 10; } if (got_break != 1) { + close(fd); return 7; } @@ -4913,6 +4919,7 @@ static int do_child_process(int pipefd, const char *name) /* Remove our lease. */ ret = fcntl(fd, F_SETLEASE, F_UNLCK); if (ret == -1) { + close(fd); return 8; }