summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/unit.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index d8ab5781b0..dc8325515c 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2400,9 +2400,11 @@ int unit_set_slice(Unit *u, Unit *slice) {
if (UNIT_DEREF(u->slice) == slice)
return 0;
- if (UNIT_ISSET(u->slice))
+ /* Disallow slice changes if @u is already bound to cgroups */
+ if (UNIT_ISSET(u->slice) && u->cgroup_realized)
return -EBUSY;
+ unit_ref_unset(&u->slice);
unit_ref_set(&u->slice, slice);
return 1;
}