mm/damon/tests/sysfs-kunit: fix use after free on error path
Subsystems (3)
PATCH 1/1 mm/damon/tests/sysfs-kunit: fix use after free on error path
Re-order these frees to avoid dereferencing "sysfs_target" after it has been freed.
Fixes ee131696794c ("mm/damon/tests/sysfs-kunit: handle alloc failures on damon_sysfs_test_add_targets()")
Signed-off-by Dan Carpenter <[email protected]>
--- mm/damon/tests/sysfs-kunit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/tests/sysfs-kunit.h +1 -1
@@ -76,8 +76,8 @@ static void damon_sysfs_test_add_targets(struct kunit *test)if (!ctx) {kfree (sysfs_targets->targets_arr);kfree (sysfs_targets); -kfree (sysfs_target);kfree (sysfs_target->regions); +kfree (sysfs_target);kunit_skip (test,"ctx alloc fail" ); }
Signature · 1 line
2.51.0
Quoted 2 lines · On Fri, 21 Nov 2025 16:36:38 +0300 Dan Carpenter <[email protected]>…
Re-order these frees to avoid dereferencing "
sysfs_target" after it has been freed.
Thank you for finding and fixing this!
Quoted 3 lines
Fixes ee131696794c ("mm/damon/tests/sysfs-kunit: handle alloc failures on damon_sysfs_test_add_targets()")Signed-off-by Dan Carpenter <[email protected]>
Reviewed-by SeongJae Park <[email protected]>
Thanks,
SJ
[...]