diff mbox series

[vfs/for-next] cgroup: fix cgroup refcnt leak

Message ID 20181227181721.24488-1-avagin@gmail.com
State New, archived
Headers show
Series [vfs/for-next] cgroup: fix cgroup refcnt leak | expand

Commit Message

Andrei Vagin Dec. 27, 2018, 6:17 p.m. UTC
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(-)

Comments

Andrei Vagin Dec. 29, 2018, 12:01 a.m. UTC | #1
Pls, ignore this patch.

On Thu, Dec 27, 2018 at 10:17:21AM -0800, Andrei Vagin wrote:
> 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
>
diff mbox series

Patch

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