From: Li Zefan Date: Mon, 29 Apr 2013 22:08:43 +0000 (-0700) Subject: memcg: avoid accessing memcg after releasing reference X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=fd0ccaf2bd04e54d2a6979fbfdcad856694e3877;p=openwrt%2Fstaging%2Fblogic.git memcg: avoid accessing memcg after releasing reference This might cause a use-after-free bug. Signed-off-by: Li Zefan Cc: Glauber Costa Acked-by: Michal Hocko Acked-by: KAMEZAWA Hiroyuki Cc: Johannes Weiner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 360464f40e96..c92bcfc5466e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3215,12 +3215,12 @@ void memcg_release_cache(struct kmem_cache *s) root = s->memcg_params->root_cache; root->memcg_params->memcg_caches[id] = NULL; - mem_cgroup_put(memcg); mutex_lock(&memcg->slab_caches_mutex); list_del(&s->memcg_params->list); mutex_unlock(&memcg->slab_caches_mutex); + mem_cgroup_put(memcg); out: kfree(s->memcg_params); }