Skip to content

Commit

Permalink
cgroup: Remove unnecessary list_empty()
Browse files Browse the repository at this point in the history
The root hasn't been removed from the root_list, so the list can't be NULL.
However, if it had been removed, attempting to destroy it once more is not
possible. Let's replace this with WARN_ON_ONCE() for clarity.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
laoar authored and htejun committed Nov 9, 2023
1 parent a12deb4 commit 96a2b48
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions kernel/cgroup/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1347,10 +1347,9 @@ static void cgroup_destroy_root(struct cgroup_root *root)

spin_unlock_irq(&css_set_lock);

if (!list_empty(&root->root_list)) {
list_del(&root->root_list);
cgroup_root_count--;
}
WARN_ON_ONCE(list_empty(&root->root_list));
list_del(&root->root_list);
cgroup_root_count--;

if (!have_favordynmods)
cgroup_favor_dynmods(root, false);
Expand Down

0 comments on commit 96a2b48

Please sign in to comment.