Commit e32978031016f56be977a9a856ba4d9f447db51f

Authored by Tejun Heo
1 parent 3ebb2b6ef3

cgroup: cgroup->subsys[] should be cleared after the css is offlined

After a css finishes offlining, offline_css() mistakenly performs
RCU_INIT_POINTER(css->cgroup->subsys[ss->id], css) which just sets the
cgroup->subsys[] pointer to the current value.  The intention was to
clear it after offline is complete, not reassign the same value.

Update it to assign NULL instead of the current value.  This makes
cgroup_css() to return NULL once offline is complete.  All the
existing users of the function either can handle NULL return already
or guarantee that the css doesn't get offlined.

While this is a bugfix, as css lifetime is currently tied to the
cgroup it belongs to, this bug doesn't cause any actual problems.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -3710,7 +3710,7 @@
3710 3710  
3711 3711 css->flags &= ~CSS_ONLINE;
3712 3712 css->cgroup->nr_css--;
3713   - RCU_INIT_POINTER(css->cgroup->subsys[ss->id], css);
  3713 + RCU_INIT_POINTER(css->cgroup->subsys[ss->id], NULL);
3714 3714 }
3715 3715  
3716 3716 /**