[PATCH 2/5] cgroup: Fix an RCU warning in alloc_css_id()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Li Zefan
Date: Thursday, April 22, 2010 - 2:30 am

With CONFIG_PROVE_RCU=y, a warning can be triggered:

  # mount -t cgroup -o memory xxx /mnt
  # mkdir /mnt/0

...
kernel/cgroup.c:4442 invoked rcu_dereference_check() without protection!
...

This is a false-positive. It's safe to directly access parent_css->id.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/cgroup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 4ca928d..3a53c77 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4561,13 +4561,13 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
 {
 	int subsys_id, i, depth = 0;
 	struct cgroup_subsys_state *parent_css, *child_css;
-	struct css_id *child_id, *parent_id = NULL;
+	struct css_id *child_id, *parent_id;
 
 	subsys_id = ss->subsys_id;
 	parent_css = parent->subsys[subsys_id];
 	child_css = child->subsys[subsys_id];
-	depth = css_depth(parent_css) + 1;
 	parent_id = parent_css->id;
+	depth = parent_id->depth;
 
 	child_id = get_new_cssid(ss, depth);
 	if (IS_ERR(child_id))
-- 
1.6.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 2/5] cgroup: Fix an RCU warning in alloc_css_id(), Li Zefan, (Thu Apr 22, 2:30 am)
Re: [PATCH 3/5] sched: Fix an RCU warning in print_task(), Peter Zijlstra, (Thu Apr 22, 3:20 am)
Re: [PATCH 1/5] cgroup: Fix an RCU warning in cgroup_path(), Paul E. McKenney, (Thu Apr 22, 12:55 pm)
Re: [PATCH 2/5] cgroup: Fix an RCU warning in alloc_css_id(), Paul E. McKenney, (Thu Apr 22, 12:55 pm)
Re: [PATCH 3/5] sched: Fix an RCU warning in print_task(), Paul E. McKenney, (Thu Apr 22, 12:56 pm)
Re: [PATCH 5/5] blk-cgroup: Fix an RCU warning in blkiocg_ ..., Paul E. McKenney, (Thu Apr 22, 12:57 pm)
Re: [PATCH 4/5] freezer cgroup: Fix an RCU warning in cgro ..., Paul E. McKenney, (Thu Apr 22, 12:59 pm)
Re: [PATCH 3/5] sched: Fix an RCU warning in print_task(), Paul E. McKenney, (Thu Apr 22, 3:05 pm)