Skip to content

Commit 9c47f91

Browse files
Jinjie Ruanmehmetb0
authored andcommitted
mm/damon/tests/sysfs-kunit.h: fix memory leak in damon_sysfs_test_add_targets()
BugLink: https://bugs.launchpad.net/bugs/2097393 commit 2d6a1c8 upstream. The sysfs_target->regions allocated in damon_sysfs_regions_alloc() is not freed in damon_sysfs_test_add_targets(), which cause the following memory leak, free it to fix it. unreferenced object 0xffffff80c2a8db80 (size 96): comm "kunit_try_catch", pid 187, jiffies 4294894363 hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc 0): [<0000000001e3714d>] kmemleak_alloc+0x34/0x40 [<000000008e6835c1>] __kmalloc_cache_noprof+0x26c/0x2f4 [<000000001286d9f8>] damon_sysfs_test_add_targets+0x1cc/0x738 [<0000000032ef8f77>] kunit_try_run_case+0x13c/0x3ac [<00000000f3edea23>] kunit_generic_run_threadfn_adapter+0x80/0xec [<00000000adf936cf>] kthread+0x2e8/0x374 [<0000000041bb1628>] ret_from_fork+0x10/0x20 Link: https://lkml.kernel.org/r/[email protected] Fixes: b8ee557 ("mm/damon/sysfs-test: add a unit test for damon_sysfs_set_targets()") Signed-off-by: Jinjie Ruan <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Koichiro Den <[email protected]>
1 parent c1d91dc commit 9c47f91

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/damon/sysfs-test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static void damon_sysfs_test_set_targets(struct kunit *test)
6767
damon_destroy_ctx(ctx);
6868
kfree(sysfs_targets->targets_arr);
6969
kfree(sysfs_targets);
70+
kfree(sysfs_target->regions);
7071
kfree(sysfs_target);
7172
}
7273

0 commit comments

Comments
 (0)