Commit 1fe4d021 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

cgroup: fix idr leak for the first cgroup root

The valid cgroup hierarchy ID range includes 0, so we can't filter for
positive numbers when freeing it, or it'll leak the first ID.  No big
deal, just disruptive when reading the code.

The ID is freed during error handling and when the reference count hits
zero, so the double-free test is not necessary; remove it.

Link: default avatarJohannes Weiner <>
Cc: Vladimir Davydov <>
Cc: Tejun Heo <>
Cc: Nikolay Borisov <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 25843c2b
......@@ -1160,18 +1160,12 @@ static void cgroup_exit_root_id(struct cgroup_root *root)
if (root->hierarchy_id) {
idr_remove(&cgroup_hierarchy_idr, root->hierarchy_id);
root->hierarchy_id = 0;
idr_remove(&cgroup_hierarchy_idr, root->hierarchy_id);
static void cgroup_free_root(struct cgroup_root *root)
if (root) {
/* hierarchy ID should already have been released */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment