]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm/damon/core: fix potential memory leak by cleaning ops_filter in damon_destroy_scheme
authorEnze Li <lienze@kylinos.cn>
Tue, 14 Oct 2025 08:42:25 +0000 (16:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2025 13:10:25 +0000 (14:10 +0100)
commit 7071537159be845a5c4ed5fb7d3db25aa4bd04a3 upstream.

Currently, damon_destroy_scheme() only cleans up the filter list but
leaves ops_filter untouched, which could lead to memory leaks when a
scheme is destroyed.

This patch ensures both filter and ops_filter are properly freed in
damon_destroy_scheme(), preventing potential memory leaks.

Link: https://lkml.kernel.org/r/20251014084225.313313-1-lienze@kylinos.cn
Fixes: ab82e57981d0 ("mm/damon/core: introduce damos->ops_filters")
Signed-off-by: Enze Li <lienze@kylinos.cn>
Reviewed-by: SeongJae Park <sj@kernel.org>
Tested-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/damon/core.c

index ce34e5abde791aeacea89099b6c4441bcbbf68bd..533c1c2d72f27c71eb783f05fea3dedc134f2bd6 100644 (file)
@@ -451,6 +451,9 @@ void damon_destroy_scheme(struct damos *s)
        damos_for_each_filter_safe(f, next, s)
                damos_destroy_filter(f);
 
+       damos_for_each_ops_filter_safe(f, next, s)
+               damos_destroy_filter(f);
+
        kfree(s->migrate_dests.node_id_arr);
        kfree(s->migrate_dests.weight_arr);
        damon_del_scheme(s);