Skip to content

Commit

Permalink
mount: don't dereference pointer before null check
Browse files Browse the repository at this point in the history
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@virtuozzo.com>
  • Loading branch information
avagin committed Oct 30, 2018
1 parent 8c817b2 commit 80d2c21
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions criu/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 80d2c21

Please sign in to comment.