Unverified Commit f576850d by Christian Brauner Committed by Stéphane Graber

conf: correctly cleanup memory in get_minimal_idmap()

Fixes: Coverity 1461760. Fixes: Coverity 1461762. Fixes: Coverity 1461763. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 82057b13
...@@ -3982,45 +3982,35 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf, ...@@ -3982,45 +3982,35 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
tmplist = malloc(sizeof(*tmplist)); tmplist = malloc(sizeof(*tmplist));
if (!tmplist) if (!tmplist)
return NULL; return NULL;
lxc_list_add_elem(tmplist, container_root_uid); /* idmap will now keep track of that memory. */
lxc_list_add_elem(tmplist, move_ptr(host_uid_map));
lxc_list_add_tail(idmap, tmplist); lxc_list_add_tail(idmap, tmplist);
if (container_root_uid) { if (container_root_uid) {
/* idmap will now keep track of that memory. */
move_ptr(container_root_uid);
/* Add container root to the map. */ /* Add container root to the map. */
tmplist = malloc(sizeof(*tmplist)); tmplist = malloc(sizeof(*tmplist));
if (!tmplist) if (!tmplist)
return NULL; return NULL;
lxc_list_add_elem(tmplist, host_uid_map); /* idmap will now keep track of that memory. */
lxc_list_add_elem(tmplist, move_ptr(container_root_uid));
lxc_list_add_tail(idmap, tmplist); lxc_list_add_tail(idmap, tmplist);
} }
/* idmap will now keep track of that memory. */
move_ptr(container_root_uid);
/* idmap will now keep track of that memory. */
move_ptr(host_uid_map);
tmplist = malloc(sizeof(*tmplist)); tmplist = malloc(sizeof(*tmplist));
if (!tmplist) if (!tmplist)
return NULL; return NULL;
lxc_list_add_elem(tmplist, container_root_gid); /* idmap will now keep track of that memory. */
lxc_list_add_elem(tmplist, move_ptr(host_gid_map));
lxc_list_add_tail(idmap, tmplist); lxc_list_add_tail(idmap, tmplist);
if (container_root_gid) { if (container_root_gid) {
/* idmap will now keep track of that memory. */
move_ptr(container_root_gid);
tmplist = malloc(sizeof(*tmplist)); tmplist = malloc(sizeof(*tmplist));
if (!tmplist) if (!tmplist)
return NULL; return NULL;
lxc_list_add_elem(tmplist, host_gid_map); /* idmap will now keep track of that memory. */
lxc_list_add_elem(tmplist, move_ptr(container_root_gid));
lxc_list_add_tail(idmap, tmplist); lxc_list_add_tail(idmap, tmplist);
} }
/* idmap will now keep track of that memory. */
move_ptr(container_root_gid);
/* idmap will now keep track of that memory. */
move_ptr(host_gid_map);
TRACE("Allocated minimal idmapping for ns uid %d and ns gid %d", nsuid, nsgid); TRACE("Allocated minimal idmapping for ns uid %d and ns gid %d", nsuid, nsgid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment