From: Igor Mammedov Date: Wed, 2 Nov 2011 20:38:21 +0000 (-0700) Subject: memcg: do not expose uninitialized mem_cgroup_per_node to world X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0a619e58703b86d53d07e938eade9a91a4a863c6;p=openwrt%2Fstaging%2Fblogic.git memcg: do not expose uninitialized mem_cgroup_per_node to world If somebody is touching data too early, it might be easier to diagnose a problem when dereferencing NULL at mem->info.nodeinfo[node] than trying to understand why mem_cgroup_per_zone is [un|partly]initialized. Signed-off-by: Igor Mammedov Acked-by: Michal Hocko Cc: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c02d87028b9f..f6c4beb4db56 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4742,7 +4742,6 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node) if (!pn) return 1; - memcg->info.nodeinfo[node] = pn; for (zone = 0; zone < MAX_NR_ZONES; zone++) { mz = &pn->zoneinfo[zone]; for_each_lru(l) @@ -4751,6 +4750,7 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node) mz->on_tree = false; mz->mem = memcg; } + memcg->info.nodeinfo[node] = pn; return 0; }