]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm/damon/sysfs-schemes: call missing mem_cgroup_iter_break()
authorSeongJae Park <sj@kernel.org>
Sun, 26 Apr 2026 17:36:12 +0000 (10:36 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 14 May 2026 00:40:00 +0000 (17:40 -0700)
damon_sysfs_memcg_path_to_id() breaks mem_cgroup_iter() loop without
calling mem_cgroup_iter_break().  This leaks the cgroup reference.  Fix
the issue by calling mem_cgroup_iter_break() before the break.

The issue was discovered [1] by Sashiko.

Link: https://lore.kernel.org/20260426173625.86521-1-sj@kernel.org
Link: https://lore.kernel.org/20260423004148.74722-1-sj@kernel.org
Fixes: 29cbb9a13f05 ("mm/damon/sysfs-schemes: implement scheme filters")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org> # 6.3.x
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/sysfs-schemes.c

index 245d63808411a204a1d36e7ade4760f94debec61..04746cbb33272d33ca0b6cca9829bac401f4cc1e 100644 (file)
@@ -2594,6 +2594,7 @@ static int damon_sysfs_memcg_path_to_id(char *memcg_path, u64 *id)
                if (damon_sysfs_memcg_path_eq(memcg, path, memcg_path)) {
                        *id = mem_cgroup_id(memcg);
                        found = true;
+                       mem_cgroup_iter_break(NULL, memcg);
                        break;
                }
        }