linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH vfs/for-next] cgroup: fix cgroup refcnt leak
@ 2018-12-27 18:17 Andrei Vagin
  2018-12-29  0:01 ` Andrei Vagin
  0 siblings, 1 reply; 2+ messages in thread
From: Andrei Vagin @ 2018-12-27 18:17 UTC (permalink / raw)
  To: Alexander Viro, David Howells; +Cc: linux-fsdevel, cgroups, 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")
Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
 kernel/cgroup/cgroup-v1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index d5ae888b8c57..5ae9b3db8bfd 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -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
-- 
2.17.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-29  0:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-27 18:17 [PATCH vfs/for-next] cgroup: fix cgroup refcnt leak Andrei Vagin
2018-12-29  0:01 ` Andrei Vagin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).