]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
memcg: do not expose uninitialized mem_cgroup_per_node to world
authorIgor Mammedov <imammedo@redhat.com>
Wed, 28 Sep 2011 00:50:55 +0000 (10:50 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 30 Sep 2011 04:53:45 +0000 (14:53 +1000)
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 <imammedo@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <>
mm/memcontrol.c

index 613f723ab3848137a4670c7c86140c0338069b92..4a8a2488b595626e266b0cc4a93f905116b470e4 100644 (file)
@@ -4743,7 +4743,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)
@@ -4752,6 +4751,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;
 }