Skip to contentSkip to conversation

cgroup: simplify cleanup in cgroup_css_set_fork()

PATCH In review Christian Brauner 3 participants 3 messages Aug 23, 2022 1 message not in the archive cgroup

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cgroup: simplify cleanup in cgroup_css_set_fork()

The call that initializes kargs->cset is find_css_set() and it is the last call in cgroup_css_set_fork(). If find_css_set() fails kargs->cset is NULL and we go to the cleanup path where we check that kargs->cset is non-NULL and if it is we call put_css_set(kargs->cset). But it'll always be NULL so put_css_set(kargs->cset) is never hit. Remove it.

Fixes ef2c41cf38a7 ("clone3: allow spawning processes into cgroups")
---
 kernel/cgroup/cgroup.c | 2 --
 1 file changed, 2 deletions(-)
kernel/cgroup/cgroup.c +0 -2
index ffaccd6373f1..2ba516205057 100644
@@ -6247,8 +6247,6 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs)
 	if (dst_cgrp)
 		cgroup_put(dst_cgrp);
 	put_css_set(cset);
-	if (kargs->cset)
-		put_css_set(kargs->cset);
 	return ret;
 }
 

base-commit: 1c23f9e627a7b412978b4e852793c5e3c3efc555

Signature · 1 line
2.34.1

A message that is not in the archive (sent off-list or not yet received): 20220823091147.846082-1-brauner-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

Reviewed-by
#3 lore raw
In reply to a message not in the archive

Hi,

Quoted 18 lines · Christian Brauner

The call that initializes kargs->cset is find_css_set() and it is the last call in cgroup_css_set_fork(). If find_css_set() fails kargs->cset is NULL and we go to the cleanup path where we check that kargs->cset is non-NULL and if it is we call put_css_set(kargs->cset). But it'll always be NULL so put_css_set(kargs->cset) is never hit. Remove it.

Fixes ef2c41cf38a7 ("clone3: allow spawning processes into cgroups")
---
  kernel/cgroup/cgroup.c | 2 --
  1 file changed, 2 deletions(-)
kernel/cgroup/cgroup.c +0 -0
index ffaccd6373f1..2ba516205057 100644

kernel/cgroup/cgroup.c static int cgroup_css_set_fork(struct kernel_clone_args *kargs) · line 6252

Quoted 8 lines
kernel/cgroup/cgroup.c +0 -2
@@ -6247,8 +6247,6 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs)
  	if (dst_cgrp)
  		cgroup_put(dst_cgrp);
  	put_css_set(cset);
-	if (kargs->cset)
-		put_css_set(kargs->cset);
  	return ret;
  }
 

LGTM.

-Mukesh

Quoted 2 lines

base-commit: 1c23f9e627a7b412978b4e852793c5e3c3efc555