Skip to content

Commit

Permalink
kunit: Fix the wrong kfree of copy for kunit_filter_suites()
Browse files Browse the repository at this point in the history
If the outer layer for loop is iterated more than once and it fails not
in the first iteration, the copy pointer has been moved. So it should free
the original copy's backup copy_start.

Fixes: abbf738 ("kunit: fix possible memory leak in kunit_filter_suites()")
Signed-off-by: Jinjie Ruan <[email protected]>
Reviewed-by: Rae Moar <[email protected]>
Reviewed-by: David Gow <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
Jinjie Ruan authored and shuahkh committed Sep 28, 2023
1 parent a6074cf commit e446795
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kunit/executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ kunit_filter_suites(const struct kunit_suite_set *suite_set,

free_copy:
if (*err)
kfree(copy);
kfree(copy_start);

return filtered;
}
Expand Down

0 comments on commit e446795

Please sign in to comment.