[CRIU] [PATCH 14/20] mnt: Sanitize collect mntinfo error path

Pavel Emelyanov xemul at parallels.com
Tue Apr 22 09:38:34 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 mount.c |   33 +++++++++++++--------------------
 1 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/mount.c b/mount.c
index def9b6e..2dc29a4 100644
--- a/mount.c
+++ b/mount.c
@@ -813,9 +813,20 @@ static int dump_one_mountpoint(struct mount_info *pm, int fd)
 	return 0;
 }
 
+static void free_mntinfo(struct mount_info *pms)
+{
+	while (pms) {
+		struct mount_info *pm;
+
+		pm = pms->next;
+		mnt_entry_free(pms);
+		pms = pm;
+	}
+}
+
 struct mount_info *collect_mntinfo(struct ns_id *ns)
 {
-	struct mount_info *pm, *p;
+	struct mount_info *pm;
 
 	if (mntns_collect_root(ns->pid) < 0)
 		return NULL;
@@ -832,14 +843,7 @@ struct mount_info *collect_mntinfo(struct ns_id *ns)
 
 	return pm;
 err:
-	while (pm) {
-		p = pm;
-		pm = pm->next;
-		xfree(p);
-	}
-
-	ns->mnt.mntinfo_tree = NULL;
-
+	free_mntinfo(pm);
 	return NULL;
 }
 
@@ -1378,17 +1382,6 @@ void mnt_entry_free(struct mount_info *mi)
 	xfree(mi);
 }
 
-static void free_mntinfo(struct mount_info *pms)
-{
-	while (pms) {
-		struct mount_info *pm;
-
-		pm = pms->next;
-		mnt_entry_free(pms);
-		pms = pm;
-	}
-}
-
 /*
  * mnt_roots is a temporary directory for restoring sub-trees of
  * non-root namespaces.
-- 
1.7.6.5


More information about the CRIU mailing list