]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
memcg: replace memcg ID idr with xarray
authorShakeel Butt <shakeel.butt@linux.dev>
Thu, 15 Aug 2024 15:54:02 +0000 (08:54 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 17 Aug 2024 00:53:05 +0000 (17:53 -0700)
fix error path in mem_cgroup_alloc(), per Dan

Link: https://lkml.kernel.org/r/20240815155402.3630804-1-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Suggested-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memcontrol.c

index d4622e600e1535a58c8c5ec249f19f135c7b2c04..cb2996d5d3f4b6f96e958e2aaf8f172d9487a71b 100644 (file)
@@ -3496,16 +3496,17 @@ static struct mem_cgroup *mem_cgroup_alloc(struct mem_cgroup *parent)
        struct mem_cgroup *memcg;
        int node, cpu;
        int __maybe_unused i;
-       long error = -ENOMEM;
+       long error;
 
        memcg = kzalloc(struct_size(memcg, nodeinfo, nr_node_ids), GFP_KERNEL);
        if (!memcg)
-               return ERR_PTR(error);
+               return ERR_PTR(-ENOMEM);
 
        error = xa_alloc(&mem_cgroup_ids, &memcg->id.id, NULL,
                         XA_LIMIT(1, MEM_CGROUP_ID_MAX), GFP_KERNEL);
        if (error)
                goto fail;
+       error = -ENOMEM;
 
        memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats),
                                 GFP_KERNEL_ACCOUNT);