Commit 77afbedf by Serge Hallyn

cgfs: don't try to remove cgroups we haven't created

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: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 4fee80f9
...@@ -935,6 +935,8 @@ static struct cgroup_process_info *lxc_cgroupfs_create(const char *name, const c ...@@ -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 * 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++) { 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); r = remove_cgroup(info_ptr->designated_mount_point, info_ptr->created_paths[info_ptr->created_paths_count - 1], false, NULL);
if (r < 0) if (r < 0)
WARN("could not clean up cgroup we created when trying to create container"); WARN("could not clean up cgroup we created when trying to create container");
......
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