Skip to contentSkip to conversation

cgroup: fix cgroup refcnt leak

PATCH In review Andrei Vagin 1 participant 2 messages Dec 27, 2018 – Dec 29, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cgroup: fix cgroup refcnt leak

Currently, we get refcnt twice if a new root isn't created.

percpu_ref_tryget_live() is called and then cgroup_get() is called too.

Fixes aea3f2676c83 ("kernfs, sysfs, cgroup, intel_rdt: Support fs_context")
---
 kernel/cgroup/cgroup-v1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cgroup-v1.c +1 -1
index d5ae888b8c57..5ae9b3db8bfd 100644
@@ -1280,8 +1280,8 @@ int cgroup1_get_tree(struct fs_context *fc)
 		mutex_lock(&cgroup_mutex);
 		percpu_ref_reinit(&root->cgrp.self.refcnt);
 		mutex_unlock(&cgroup_mutex);
+		cgroup_get(&root->cgrp);
 	}
-	cgroup_get(&root->cgrp);
 
 	/*
 	 * If @pinned_sb, we're reusing an existing root and holding an
Signature · 1 line
2.17.2
#1 lore raw

Pls, ignore this patch.

Quoted 27 lines · Andrei Vagin

Currently, we get refcnt twice if a new root isn't created.

percpu_ref_tryget_live() is called and then cgroup_get() is called too.

Fixes aea3f2676c83 ("kernfs, sysfs, cgroup, intel_rdt: Support fs_context")
---
 kernel/cgroup/cgroup-v1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cgroup-v1.c +1 -1
index d5ae888b8c57..5ae9b3db8bfd 100644
@@ -1280,8 +1280,8 @@ int cgroup1_get_tree(struct fs_context *fc)
 		mutex_lock(&cgroup_mutex);
 		percpu_ref_reinit(&root->cgrp.self.refcnt);
 		mutex_unlock(&cgroup_mutex);
+		cgroup_get(&root->cgrp);
 	}
-	cgroup_get(&root->cgrp);
 
 	/*
 	 * If @pinned_sb, we're reusing an existing root and holding an
Signature · 1 line
2.17.2