[PATCH] mm/memcg: check kzalloc_node() return in memcg1_init()

From: Hongfu Li

Date: Tue Jul 21 2026 - 06:12:47 EST


From: Hongfu Li <lihongfu@xxxxxxxxxx>

Add NULL check for per-node kzalloc_node() allocations in memcg1_init().

Skip the NUMA node when allocation fails. All users of
soft_limit_tree.rb_tree_per_node[] safely handle NULL entries, only losing
soft-limit tracking for that node.

Signed-off-by: Hongfu Li <lihongfu@xxxxxxxxxx>
---
mm/memcontrol-v1.c | 2 +++++
1 file changed, 2 insertions(+)

diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c
index 2dc599484d00..33ea693c9281 100644
--- a/mm/memcontrol-v1.c
+++ b/mm/memcontrol-v1.c
@@ -2566,6 +2566,8 @@ static int __init memcg1_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.54.0