Skip to content

Commit

Permalink
mount: Resource leak (RESOURCE_LEAK)
Browse files Browse the repository at this point in the history
CID 226486 (#1 of 2): Resource leak (RESOURCE_LEAK)
 Variable mi going out of scope leaks the storage it points to.

CID 226486 (#2 of 2): Resource leak (RESOURCE_LEAK)
 Variable mi going out of scope leaks the storage it points to.

Signed-off-by: Adrian Reber <[email protected]>
  • Loading branch information
adrianreber authored and avagin committed Oct 20, 2020
1 parent c1ab1a1 commit 03d6639
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions criu/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ static __maybe_unused int add_cr_time_mount(struct mount_info *root, char *fsnam

mi->mountpoint = xmalloc(len + strlen(path) + 1);
if (!mi->mountpoint)
return -1;
goto err;
mi->ns_mountpoint = mi->mountpoint;
if (!add_slash)
sprintf(mi->mountpoint, "%s%s", root->mountpoint, path);
Expand All @@ -1497,7 +1497,7 @@ static __maybe_unused int add_cr_time_mount(struct mount_info *root, char *fsnam
mi->source = xstrdup(fsname);
mi->options = xstrdup("");
if (!mi->root || !mi->fsname || !mi->source || !mi->options)
return -1;
goto err;
mi->fstype = find_fstype_by_name(fsname);

mi->s_dev = mi->s_dev_rt = s_dev;
Expand All @@ -1523,6 +1523,10 @@ static __maybe_unused int add_cr_time_mount(struct mount_info *root, char *fsnam
pr_info("Add cr-time mountpoint %s with parent %s(%u)\n",
mi->mountpoint, parent->mountpoint, parent->mnt_id);
return 0;

err:
mnt_entry_free(mi);
return -1;
}

/* Returns 1 in case of success, -errno in case of mount fail, and 0 on other errors */
Expand Down

0 comments on commit 03d6639

Please sign in to comment.