Skip to content

Commit 2f7659a

Browse files
Muchun Songtorvalds
authored andcommitted
mm: memcg/slab: fix return of child memcg objcg for root memcg
Consider the following memcg hierarchy. root / \ A B If we failed to get the reference on objcg of memcg A, the get_obj_cgroup_from_current can return the wrong objcg for the root memcg. Link: https://lkml.kernel.org/r/[email protected] Fixes: bf4f059 ("mm: memcg/slab: obj_cgroup API") Signed-off-by: Muchun Song <[email protected]> Acked-by: Roman Gushchin <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Yafang Shao <[email protected]> Cc: Chris Down <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Kees Cook <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Eugene Syromiatnikov <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Adrian Reber <[email protected]> Cc: Marco Elver <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 378876b commit 2f7659a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/memcontrol.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,6 +2975,7 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void)
29752975
objcg = rcu_dereference(memcg->objcg);
29762976
if (objcg && obj_cgroup_tryget(objcg))
29772977
break;
2978+
objcg = NULL;
29782979
}
29792980
rcu_read_unlock();
29802981

0 commit comments

Comments
 (0)