diff mbox series

[17/19] Removed resource leaks from mountd/cache.c

Message ID 20190508133536.6077-18-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
mountd/cache.c:1244:3: warning: statement will never be
	executed [-Wswitch-unreachable]

mountd/cache.c:1260: leaked_storage: Variable "locations"
	going out of scope leaks the storage it points to.

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 utils/mountd/cache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index 2cb370f..bdbd190 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -1240,7 +1240,7 @@  static struct exportent *lookup_junction(char *dom, const char *pathname,
 		goto out;
 	}
 	status = nfs_get_basic_junction(pathname, &locations);
-	switch (status) {
+	if (status) {
 		xlog(L_WARNING, "Dangling junction %s: %s",
 			pathname, strerror(status));
 		goto out;
@@ -1248,10 +1248,11 @@  static struct exportent *lookup_junction(char *dom, const char *pathname,
 
 	parent = lookup_parent_export(dom, pathname, ai);
 	if (parent == NULL)
-		goto out;
+		goto free_locations;
 
 	exp = locations_to_export(locations, pathname, parent);
 
+free_locations:
 	nfs_free_locations(locations->ns_list);
 	free(locations);