[CRIU] [PATCH 3/4] mount: don't dereference pointer before null check

Andrei Vagin avagin at virtuozzo.com
Thu Jul 12 23:41:44 MSK 2018


CID 190775 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking m->parent suggests that it may be null,
but it has already been dereferenced on all paths leading to the check.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/mount.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/criu/mount.c b/criu/mount.c
index 9cc8f6e94..f347a2e28 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -833,13 +833,14 @@ static int resolve_external_mounts(struct mount_info *info)
 static int root_path_from_parent(struct mount_info *m, char *buf, int size)
 {
 	bool head_slash = false, tail_slash = false;
-	int p_len = strlen(m->parent->mountpoint),
-	    m_len = strlen(m->mountpoint),
-	    len;
+	int p_len, m_len, len;
 
 	if (!m->parent)
 		return -1;
 
+	p_len = strlen(m->parent->mountpoint),
+	m_len = strlen(m->mountpoint),
+
 	len = snprintf(buf, size, "%s", m->parent->root);
 	if (len >= size)
 		return -1;
-- 
2.14.3



More information about the CRIU mailing list