[1/4] exportfs: Fix a few valgrind warnings
diff mbox series

Message ID 20200722055354.28132-2-nazard@nazar.ca
State New
Headers show
Series
  • nfs-utils patches
Related show

Commit Message

Doug Nazar July 22, 2020, 5:53 a.m. UTC
Signed-off-by: Doug Nazar <nazard@nazar.ca>
---
 support/nfs/exports.c     | 1 +
 utils/exportfs/exportfs.c | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index 97eb3183..037febd0 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -838,6 +838,7 @@  struct export_features *get_export_features(void)
 	close(fd);
 	if (c == -1)
 		goto err;
+	buf[c] = 0;
 	c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags);
 	if (c != 2)
 		goto err;
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index a04a7898..cde5e517 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -85,8 +85,11 @@  grab_lockfile()
 static void
 release_lockfile()
 {
-	if (_lockfd != -1)
+	if (_lockfd != -1) {
 		lockf(_lockfd, F_ULOCK, 0);
+		close(_lockfd);
+		_lockfd = -1;
+	}
 }
 
 int
@@ -184,6 +187,7 @@  main(int argc, char **argv)
 			xtab_export_read();
 			dump(f_verbose, f_export_format);
 			free_state_path_names(&etab);
+			export_freeall();
 			return 0;
 		}
 	}
@@ -225,6 +229,7 @@  main(int argc, char **argv)
 	xtab_export_write();
 	cache_flush(force_flush);
 	free_state_path_names(&etab);
+	export_freeall();
 
 	return export_errno;
 }