aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2016-06-17 12:23:59 -0400
committerTejun Heo <tj@kernel.org>2016-06-17 14:16:28 -0400
commit8c8a5502183c724854afd2f143a72f7eb71b6fea (patch)
tree8d9c0a06d651b1b6429d8a4968570c0b0013115f /kernel/cgroup.c
parentdb06d759d6cf903aeda8c107fd3abd366dd80200 (diff)
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. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 86cb5c6e8932..36fc0ff506c3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1158,18 +1158,12 @@ static void cgroup_exit_root_id(struct cgroup_root *root)
1158{ 1158{
1159 lockdep_assert_held(&cgroup_mutex); 1159 lockdep_assert_held(&cgroup_mutex);
1160 1160
1161 if (root->hierarchy_id) { 1161 idr_remove(&cgroup_hierarchy_idr, root->hierarchy_id);
1162 idr_remove(&cgroup_hierarchy_idr, root->hierarchy_id);
1163 root->hierarchy_id = 0;
1164 }
1165} 1162}
1166 1163
1167static void cgroup_free_root(struct cgroup_root *root) 1164static void cgroup_free_root(struct cgroup_root *root)
1168{ 1165{
1169 if (root) { 1166 if (root) {
1170 /* hierarchy ID should already have been released */
1171 WARN_ON_ONCE(root->hierarchy_id);
1172
1173 idr_destroy(&root->cgroup_idr); 1167 idr_destroy(&root->cgroup_idr);
1174 kfree(root); 1168 kfree(root);
1175 } 1169 }