]> git.proxmox.com Git - mirror_lxc.git/commitdiff
cgfs: don't try to remove cgroups we haven't created
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 3 Mar 2016 00:11:14 +0000 (16:11 -0800)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 3 Mar 2016 00:11:14 +0000 (16:11 -0800)
info_ptr->created_paths_count can be 0, so don't blindly dereference
info_ptr->created_paths[ created_paths_count - 1].  Apparently we never
used to have 0 at the cleanup_name_on_this_level before, but now that
we can fail with -eperm and not just -eexist, we do.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/cgfs.c

index 0eb47a1d7aada5828e9acb2091f1d70b98384b47..05e7bcfd93689152ec08cd20a80a7efa11951c5a 100644 (file)
@@ -935,6 +935,8 @@ static struct cgroup_process_info *lxc_cgroupfs_create(const char *name, const c
                 * In that case, remove the cgroup from all previous hierarchies
                 */
                for (j = 0, info_ptr = base_info; j < i && info_ptr; info_ptr = info_ptr->next, j++) {
+                       if (info_ptr->created_paths_count < 1)
+                               continue;
                        r = remove_cgroup(info_ptr->designated_mount_point, info_ptr->created_paths[info_ptr->created_paths_count - 1], false, NULL);
                        if (r < 0)
                                WARN("could not clean up cgroup we created when trying to create container");