[CRIU] [PATCH] mount: fix dereference after null check

Andrey Vagin avagin at openvz.org
Wed Aug 6 06:47:43 PDT 2014


CID 1168169 (#1 of 1): Dereference after null check (FORWARD_NULL)
7. var_deref_model: Passing "mi" to function "do_bind_mount(struct
   mount_info *)", which dereferences null "mi->bind"

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 mount.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mount.c b/mount.c
index 24cbfe9..88631f8 100644
--- a/mount.c
+++ b/mount.c
@@ -1306,7 +1306,7 @@ static int restore_ext_mount(struct mount_info *mi)
 
 static int do_bind_mount(struct mount_info *mi)
 {
-	bool shared = mi->shared_id && mi->shared_id == mi->bind->shared_id;
+	bool shared = 0;
 
 	if (!mi->need_plugin) {
 		char *root, rpath[PATH_MAX];
@@ -1323,6 +1323,8 @@ static int do_bind_mount(struct mount_info *mi)
 			goto do_bind;
 		}
 
+		shared = mi->shared_id && mi->shared_id == mi->bind->shared_id;
+
 		/*
 		 * Cut common part of root.
 		 * For non-root binds the source is always "/" (checked)
-- 
1.8.5.3



More information about the CRIU mailing list