[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230615073226.1343-2-haifeng.xu@shopee.com>
Date: Thu, 15 Jun 2023 07:32:26 +0000
From: Haifeng Xu <haifeng.xu@...pee.com>
To: mhocko@...e.com
Cc: roman.gushchin@...ux.dev, hannes@...xchg.org, shakeelb@...gle.com,
akpm@...ux-foundation.org, cgroups@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Haifeng Xu <haifeng.xu@...pee.com>
Subject: [PATCH 2/2] mm/memcontrol: add check for allocation failure in mem_cgroup_init()
If mem_cgroup_init() fails to allocate mem_cgroup_tree_per_node, we
should not try to initilaize it. Add check for this case to avoid
potential NULL pointer dereference.
Signed-off-by: Haifeng Xu <haifeng.xu@...pee.com>
---
mm/memcontrol.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c73c5fb33f65..7ebf64e48b25 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -7422,6 +7422,8 @@ static int __init mem_cgroup_init(void)
struct mem_cgroup_tree_per_node *rtpn;
rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, node);
+ if (!rtpn)
+ continue;
rtpn->rb_root = RB_ROOT;
rtpn->rb_rightmost = NULL;
--
2.25.1
Powered by blists - more mailing lists