Skip to content

Commit

Permalink
memcg: avoid accessing memcg after releasing reference
Browse files Browse the repository at this point in the history
This might cause a use-after-free bug.

Signed-off-by: Li Zefan <[email protected]>
Cc: Glauber Costa <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Johannes Weiner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
lizf-os authored and torvalds committed Apr 29, 2013
1 parent 865ffef commit fd0ccaf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fd0ccaf

Please sign in to comment.