From: Jinjie Ruan ruanjinjie@huawei.com
stable inclusion from stable-v6.6.2 commit 421058c75b8339d5d898a8cde36e058cdf85393e category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8IW7G
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=...
--------------------------------
[ 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 Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- lib/kunit/executor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c index a037a46fae5e..9358ed2df839 100644 --- a/lib/kunit/executor.c +++ b/lib/kunit/executor.c @@ -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; }