kunit: Fix the wrong kfree of copy for kunit_filter_suites()

[ Upstream commit e44679515a7b803cf0143dc9de3d2ecbe907f939 ]

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: abbf73816b6f ("kunit: fix possible memory leak in kunit_filter_suites()")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jinjie Ruan 2023-09-27 17:03:48 +08:00 committed by Greg Kroah-Hartman
parent 3fc7c7079f
commit 421058c75b

View File

@ -243,7 +243,7 @@ free_parsed_glob:
free_copy:
if (*err)
kfree(copy);
kfree(copy_start);
return filtered;
}