48 lines
1.0 KiB
Diff
48 lines
1.0 KiB
Diff
From 9d013b1bcc6277842824b25241e8652a865a2944 Mon Sep 17 00:00:00 2001
|
|
From: Simo Sorce <simo@redhat.com>
|
|
Date: Wed, 18 Oct 2023 15:55:13 -0400
|
|
Subject: [PATCH] Do not close fd if it was never set
|
|
|
|
Fixes Coverity 403648: Argument cannot be negative
|
|
|
|
Signed-off-by: Simo Sorce <simo@redhat.com>
|
|
---
|
|
src/gp_init.c | 10 +++++++---
|
|
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/gp_init.c b/src/gp_init.c
|
|
index 8d72c3e..5e7074f 100644
|
|
--- a/src/gp_init.c
|
|
+++ b/src/gp_init.c
|
|
@@ -379,12 +379,14 @@ int init_event_fini(struct gssproxy_ctx *gpctx)
|
|
static int try_init_proc_nfsd(void)
|
|
{
|
|
char buf[] = "1";
|
|
- int fd, ret;
|
|
static bool poked = false;
|
|
static bool warned_once = false;
|
|
+ int fd = 1;
|
|
+ int ret;
|
|
|
|
- if (poked)
|
|
+ if (poked) {
|
|
return 0;
|
|
+ }
|
|
|
|
fd = open(LINUX_PROC_USE_GSS_PROXY_FILE, O_RDWR);
|
|
if (fd == -1) {
|
|
@@ -411,7 +413,9 @@ static int try_init_proc_nfsd(void)
|
|
ret = 0;
|
|
|
|
out:
|
|
- close(fd);
|
|
+ if (fd != -1) {
|
|
+ close(fd);
|
|
+ }
|
|
return ret;
|
|
}
|
|
|
|
--
|
|
2.43.0
|
|
|