summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorWang Xiaolei <xiaoleiwangxiaolei@gmail.com>2026-11-02 06:46:25 -0800
committerAndrew Morton <akpm@linux-foundation.org>2026-11-09 22:44:29 -0800
commit9d2cc214935ad78b8f54bf886f0b4e3f387fa44f (patch)
tree2a7a596088c2f4ddd9dc675c3fc9079301de41b7 /include/linux
parent5fe092741502770107a0be7b3885ce55f7761f01 (diff)
mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test
damon_sysfs_test_add_targets() creates its monitoring context with damon_new_ctx(), which leaves ctx->ops zero-initialized. Since DAMON_OPS_VADDR is zero, damon_target_has_pid() returns true for the context, and damon_sysfs_add_targets() therefore calls damon_set_target_pid() for each target it adds. That function grabs a reference to the target's struct pid via find_get_pid(). The test then tears the context down with damon_destroy_ctx(), which releases such a reference from ctx->ops.cleanup_target(). For the vaddr operations set that callback is damon_va_cleanup_target(), and it is the only place where the reference is put. The test never selects an operations set, though, so cleanup_target is NULL and both references -- one for each of the two damon_sysfs_add_targets() calls -- are leaked on every run of the test. Running the test with CONFIG_DEBUG_KMEMLEAK enabled reports the leaked struct pid objects as unreferenced. Fix this by selecting the vaddr operations set for the context before adding the targets, mirroring what the sysfs interface does. damon_select_ops() fails if the vaddr operations set is not registered, in which case the test cannot exercise the pid handling and skips itself. Link: https://lore.kernel.org/20261102144627.88843-3-sj@kernel.org Fixes: b8ee5575f763 ("mm/damon/sysfs-test: add a unit test for damon_sysfs_set_targets()") Signed-off-by: Wang Xiaolei <xiaoleiwangxiaolei@gmail.com> Signed-off-by: SJ Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: SJ Park <sj@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: "Liam R. Howlett" <liam@infradead.org> Cc: Brendan Higgins <brendan.higgins@linux.dev> Cc: David Gow <davidgow@davidgow.net> Cc: Aveline Noir <jm5905938@gmail.com> Cc: <stable@vger.kernel.org> # 6.7.x
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions