提交 bed274bc 编写于 作者: L Lu Jialin 提交者: Yang Yingliang

memcg: fix unsuitable null check after alloc memory

hulk inclusion
category: bugfix
bugzilla: 51815, https://gitee.com/openeuler/kernel/issues/I3IJ9I
CVE: NA

--------
Signed-off-by: NLu Jialin <lujialin4@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f6ca4176
...@@ -4850,8 +4850,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) ...@@ -4850,8 +4850,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
if (!node_state(node, N_NORMAL_MEMORY)) if (!node_state(node, N_NORMAL_MEMORY))
tmp = -1; tmp = -1;
pn_ext = kzalloc_node(sizeof(*pn_ext), GFP_KERNEL, tmp); pn_ext = kzalloc_node(sizeof(*pn_ext), GFP_KERNEL, tmp);
pn = &pn_ext->pn; if (!pn_ext)
if (!pn)
return 1; return 1;
pn_ext->lruvec_stat_local = alloc_percpu(struct lruvec_stat); pn_ext->lruvec_stat_local = alloc_percpu(struct lruvec_stat);
...@@ -4860,6 +4859,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) ...@@ -4860,6 +4859,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
return 1; return 1;
} }
pn = &pn_ext->pn;
pn->lruvec_stat_cpu = alloc_percpu(struct lruvec_stat); pn->lruvec_stat_cpu = alloc_percpu(struct lruvec_stat);
if (!pn->lruvec_stat_cpu) { if (!pn->lruvec_stat_cpu) {
free_percpu(pn_ext->lruvec_stat_local); free_percpu(pn_ext->lruvec_stat_local);
...@@ -4927,10 +4927,10 @@ static struct mem_cgroup *mem_cgroup_alloc(void) ...@@ -4927,10 +4927,10 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
size += nr_node_ids * sizeof(struct mem_cgroup_per_node *); size += nr_node_ids * sizeof(struct mem_cgroup_per_node *);
memcg_ext = kzalloc(size, GFP_KERNEL); memcg_ext = kzalloc(size, GFP_KERNEL);
memcg = &memcg_ext->memcg; if (!memcg_ext)
if (!memcg)
return NULL; return NULL;
memcg = &memcg_ext->memcg;
memcg->id.id = idr_alloc(&mem_cgroup_idr, NULL, memcg->id.id = idr_alloc(&mem_cgroup_idr, NULL,
1, MEM_CGROUP_ID_MAX, 1, MEM_CGROUP_ID_MAX,
GFP_KERNEL); GFP_KERNEL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册