From: Christian Brauner Date: Wed, 17 Feb 2021 08:28:46 +0000 (+0100) Subject: cgroups: ensure leaf cgroup is correctly pruned on creation failure X-Git-Tag: lxc-5.0.0~281^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c880cdfa1d3be358c4ab04f6346c21213bbca9a;p=thirdparty%2Flxc.git cgroups: ensure leaf cgroup is correctly pruned on creation failure Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 8a9f584e2..396d81675 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -1159,8 +1159,8 @@ static bool cgroup_tree_create(struct cgroup_ops *ops, struct lxc_conf *conf, return true; } -static void cgroup_tree_leaf_remove(struct hierarchy *h, const char *path_prune, - bool payload) +static void cgroup_tree_prune_leaf(struct hierarchy *h, const char *path_prune, + bool payload) { int ret; @@ -1357,9 +1357,9 @@ __cgfsng_ops static bool cgfsng_monitor_create(struct cgroup_ops *ops, struct lx continue; DEBUG("Failed to create cgroup \"%s\"", maybe_empty(ops->hierarchies[i]->monitor_full_path)); - for (int j = 0; j < i; j++) - cgroup_tree_leaf_remove(ops->hierarchies[j], - monitor_cgroup, false); + for (int j = 0; j <= i; j++) + cgroup_tree_prune_leaf(ops->hierarchies[j], + monitor_cgroup, false); idx++; break; @@ -1456,10 +1456,10 @@ __cgfsng_ops static bool cgfsng_payload_create(struct cgroup_ops *ops, struct lx continue; DEBUG("Failed to create cgroup \"%s\"", ops->hierarchies[i]->container_full_path ?: "(null)"); - for (int j = 0; j < i; j++) - cgroup_tree_leaf_remove(ops->hierarchies[j], - limiting_cgroup ?: container_cgroup, - true); + for (int j = 0; j <= i; j++) + cgroup_tree_prune_leaf(ops->hierarchies[j], + limiting_cgroup ?: container_cgroup, + true); idx++; break;