diff mbox

[5/7] mount: fix memory leak in v4root_add_parents

Message ID 146976861678.20186.788066493232715792.stgit@noble (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown July 29, 2016, 5:03 a.m. UTC
If pseudofs_update failed, we weren't freeing 'path'.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 utils/mountd/v4root.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/mountd/v4root.c b/utils/mountd/v4root.c
index d52172592823..f978f4ceef01 100644
--- a/utils/mountd/v4root.c
+++ b/utils/mountd/v4root.c
@@ -152,6 +152,7 @@  static int v4root_add_parents(nfs_export *exp)
 	char *hostname = exp->m_export.e_hostname;
 	char *path;
 	char *ptr;
+	int ret = 0;
 
 	path = strdup(exp->m_export.e_path);
 	if (!path) {
@@ -160,19 +161,18 @@  static int v4root_add_parents(nfs_export *exp)
 		return -ENOMEM;
 	}
 	for (ptr = path; ptr; ptr = strchr(ptr, '/')) {
-		int ret;
 		char saved;
 
 		saved = *ptr;
 		*ptr = '\0';
 		ret = pseudofs_update(hostname, *path ? path : "/", exp);
 		if (ret)
-			return ret;
+			break;
 		*ptr = saved;
 		ptr++;
 	}
 	free(path);
-	return 0;
+	return ret;
 }
 
 /*