mirror of https://github.com/torvalds/linux.git
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. Link: https://lkml.kernel.org/r/aSBq5uSPIqsqH8zO@stanley.mountain Fixes: ee131696794c ("mm/damon/tests/sysfs-kunit: handle alloc failures on damon_sysfs_test_add_targets()") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
348ced3da5
commit
a9ce09b157
|
|
@ -76,8 +76,8 @@ static void damon_sysfs_test_add_targets(struct kunit *test)
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
kfree(sysfs_targets->targets_arr);
|
kfree(sysfs_targets->targets_arr);
|
||||||
kfree(sysfs_targets);
|
kfree(sysfs_targets);
|
||||||
kfree(sysfs_target);
|
|
||||||
kfree(sysfs_target->regions);
|
kfree(sysfs_target->regions);
|
||||||
|
kfree(sysfs_target);
|
||||||
kunit_skip(test, "ctx alloc fail");
|
kunit_skip(test, "ctx alloc fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue