diff options
-rw-r--r-- | kernel/cgroup.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index a5dccd4c2360..a4c47d1b3cec 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -378,12 +378,20 @@ static void __put_css_set(struct css_set *cg, int taskexit) struct cgroup *cgrp = link->cgrp; list_del(&link->cg_link_list); list_del(&link->cgrp_link_list); + + /* + * We may not be holding cgroup_mutex, and if cgrp->count is + * dropped to 0 the cgroup can be destroyed at any time, hence + * rcu_read_lock is used to keep it alive. + */ + rcu_read_lock(); if (atomic_dec_and_test(&cgrp->count) && notify_on_release(cgrp)) { if (taskexit) set_bit(CGRP_RELEASABLE, &cgrp->flags); check_for_release(cgrp); } + rcu_read_unlock(); kfree(link); } |