diff mbox series

[08/19] Removed resource leaks from nfsidmap/libnfsidmap.c

Message ID 20190508133536.6077-9-steved@redhat.com (mailing list archive)
State New, archived
Headers show
Series Covertity Scan: Removed resources leaks | expand

Commit Message

Steve Dickson May 8, 2019, 1:35 p.m. UTC
nfsidmap/libnfsidmap.c:410: leaked_storage: Variable "nfs4_methods"
	going out of scope leaks the storage it points to.

ibnfsidmap.c:483: leaked_storage: Variable "gss_methods"
	going out of scope leaks the storage it points to.

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 support/nfsidmap/libnfsidmap.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
index 35ddf01..7b8a871 100644
--- a/support/nfsidmap/libnfsidmap.c
+++ b/support/nfsidmap/libnfsidmap.c
@@ -406,8 +406,10 @@  int nfs4_init_name_mapping(char *conffile)
 	nfs4_methods = conf_get_list("Translation", "Method");
 	if (nfs4_methods) {
 		IDMAP_LOG(1, ("libnfsidmap: processing 'Method' list"));
-		if (load_plugins(nfs4_methods, &nfs4_plugins) == -1)
+		if (load_plugins(nfs4_methods, &nfs4_plugins) == -1) {
+			conf_free_list(nfs4_methods);
 			return -ENOENT;
+		}
 	} else {
 		struct conf_list list;
 		struct conf_list_node node;
@@ -475,11 +477,15 @@  out:
 	if (ret) {
 		if (nfs4_plugins)
 			unload_plugins(nfs4_plugins);
-		if (gss_plugins)
+		if (gss_plugins) {
 			unload_plugins(gss_plugins);
+		}
 		nfs4_plugins = gss_plugins = NULL;
 	}
 
+	if (gss_methods)
+		conf_free_list(gss_methods);
+
 	return ret ? -ENOENT: 0;
 }