* [folded-merged] mm-memcontrol-convert-objcg-to-be-per-memcg-per-node-type-fix-fix-fix-2.patch removed from -mm tree
@ 2026-03-24 23:16 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-03-24 23:16 UTC (permalink / raw)
To: mm-commits, zhengqi.arch, shakeel.butt, roman.gushchin,
muchun.song, mhocko, hannes, devnexen, akpm
The quilt patch titled
Subject: mm/memcontrol: fix obj_cgroup leak in mem_cgroup_css_online() error path
has been removed from the -mm tree. Its filename was
mm-memcontrol-convert-objcg-to-be-per-memcg-per-node-type-fix-fix-fix-2.patch
This patch was dropped because it was folded into mm-memcontrol-convert-objcg-to-be-per-memcg-per-node-type.patch
------------------------------------------------------
From: David Carlier <devnexen@gmail.com>
Subject: mm/memcontrol: fix obj_cgroup leak in mem_cgroup_css_online() error path
Date: Sun, 22 Mar 2026 19:36:31 +0000
When obj_cgroup_alloc() fails partway through the NUMA node loop in
mem_cgroup_css_online(), the free_objcg error path drops the extra
reference held by pn->orig_objcg but never kills the initial percpu_ref
from obj_cgroup_alloc() stored in pn->objcg.
Since css_offline is never called when css_online fails,
memcg_reparent_objcgs() never runs, so the percpu_ref_kill() that normally
drops this initial reference never executes. The obj_cgroup and its
per-cpu ref allocations are leaked.
Clear pn->objcg via rcu_replace_pointer() and add the missing
percpu_ref_kill() in the error path, matching the normal teardown sequence
in memcg_reparent_objcgs().
Also add a NULL check for pn in __mem_cgroup_free() to prevent a NULL
pointer dereference when alloc_mem_cgroup_per_node_info() fails partway
through the node loop in mem_cgroup_alloc().
Link: https://lkml.kernel.org/r/20260322193631.45457-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Acked-by: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/memcontrol.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- a/mm/memcontrol.c~mm-memcontrol-convert-objcg-to-be-per-memcg-per-node-type-fix-fix-fix-2
+++ a/mm/memcontrol.c
@@ -3854,6 +3854,8 @@ static void __mem_cgroup_free(struct mem
for_each_node(node) {
struct mem_cgroup_per_node *pn = memcg->nodeinfo[node];
+ if (!pn)
+ continue;
obj_cgroup_put(pn->orig_objcg);
free_mem_cgroup_per_node_info(pn);
@@ -4055,8 +4057,11 @@ static int mem_cgroup_css_online(struct
free_objcg:
for_each_node(nid) {
struct mem_cgroup_per_node *pn = memcg->nodeinfo[nid];
+ objcg = rcu_replace_pointer(pn->objcg, NULL, true);
+ if (objcg)
+ percpu_ref_kill(&objcg->refcnt);
- if (pn && pn->orig_objcg) {
+ if (pn->orig_objcg) {
obj_cgroup_put(pn->orig_objcg);
/*
* Reset pn->orig_objcg to NULL to prevent
_
Patches currently in -mm which might be from devnexen@gmail.com are
mm-hugetlb-restore-reservation-on-error-in-hugetlb_mfill_atomic_pte-resubmission-path.patch
mm-memcontrol-convert-objcg-to-be-per-memcg-per-node-type.patch
mm-memcontrol-convert-objcg-to-be-per-memcg-per-node-type-fix-fix-fix-2-fix.patch
mm-page_io-fix-pswpin-undercount-for-large-folios-in-sio_read_complete.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-24 23:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 23:16 [folded-merged] mm-memcontrol-convert-objcg-to-be-per-memcg-per-node-type-fix-fix-fix-2.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.