diff mbox series

[nfs-utils,1/5] nfsdcld: Fix a few Coverity Scan RESOURCE_LEAK errors

Message ID 20200710203700.2546112-2-smayhew@redhat.com (mailing list archive)
State New, archived
Headers show
Series nfsdcld: Fix a number of Coverity Scan | expand

Commit Message

Scott Mayhew July 10, 2020, 8:36 p.m. UTC
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 utils/nfsdcld/legacy.c  | 2 ++
 utils/nfsdcld/nfsdcld.c | 1 +
 utils/nfsdcld/sqlite.c  | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c
index 3c6bea6..b8ea4ff 100644
--- a/utils/nfsdcld/legacy.c
+++ b/utils/nfsdcld/legacy.c
@@ -60,6 +60,7 @@  legacy_load_clients_from_recdir(int *num_records)
 	}
 	if (read(fd, recdirname, PATH_MAX) < 0) {
 		xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE);
+		close(fd);
 		return;
 	}
 	close(fd);
@@ -135,6 +136,7 @@  legacy_clear_recdir(void)
 	}
 	if (read(fd, recdirname, PATH_MAX) < 0) {
 		xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE);
+		close(fd);
 		return;
 	}
 	close(fd);
diff --git a/utils/nfsdcld/nfsdcld.c b/utils/nfsdcld/nfsdcld.c
index be65562..bb8e365 100644
--- a/utils/nfsdcld/nfsdcld.c
+++ b/utils/nfsdcld/nfsdcld.c
@@ -331,6 +331,7 @@  cld_check_grace_period(void)
 	if (read(fd, &c, 1) < 0) {
 		xlog(L_WARNING, "Unable to read from %s: %m",
 			NFSD_END_GRACE_FILE);
+		close(fd);
 		return 1;
 	}
 	close(fd);
diff --git a/utils/nfsdcld/sqlite.c b/utils/nfsdcld/sqlite.c
index 6666c86..e61e67c 100644
--- a/utils/nfsdcld/sqlite.c
+++ b/utils/nfsdcld/sqlite.c
@@ -380,7 +380,7 @@  sqlite_maindb_init_v4(void)
 				&err);
 	if (ret != SQLITE_OK) {
 		xlog(L_ERROR, "Unable to begin transaction: %s", err);
-		return ret;
+		goto out;
 	}
 
 	/*