From: Serge Hallyn Date: Thu, 3 Mar 2016 00:11:14 +0000 (-0800) Subject: cgfs: don't try to remove cgroups we haven't created X-Git-Tag: lxc-2.0.0.rc5~4^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77afbedf09ed41592817ecd6491ed8ada3babba9;p=thirdparty%2Flxc.git 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: Serge Hallyn --- diff --git a/src/lxc/cgfs.c b/src/lxc/cgfs.c index 0eb47a1d7..05e7bcfd9 100644 --- a/src/lxc/cgfs.c +++ b/src/lxc/cgfs.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 */ 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");