Skip to content

Commit 9d013b1

Browse files
committed
Do not close fd if it was never set
Fixes Coverity 403648: Argument cannot be negative Signed-off-by: Simo Sorce <simo@redhat.com>
1 parent fb8737b commit 9d013b1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/gp_init.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,14 @@ int init_event_fini(struct gssproxy_ctx *gpctx)
379379
static int try_init_proc_nfsd(void)
380380
{
381381
char buf[] = "1";
382-
int fd, ret;
383382
static bool poked = false;
384383
static bool warned_once = false;
384+
int fd = 1;
385+
int ret;
385386

386-
if (poked)
387+
if (poked) {
387388
return 0;
389+
}
388390

389391
fd = open(LINUX_PROC_USE_GSS_PROXY_FILE, O_RDWR);
390392
if (fd == -1) {
@@ -411,7 +413,9 @@ static int try_init_proc_nfsd(void)
411413
ret = 0;
412414

413415
out:
414-
close(fd);
416+
if (fd != -1) {
417+
close(fd);
418+
}
415419
return ret;
416420
}
417421

0 commit comments

Comments
 (0)