From: Jinjie Ruan Date: Wed, 27 Sep 2023 09:03:48 +0000 (+0800) Subject: kunit: Fix the wrong kfree of copy for kunit_filter_suites() X-Git-Tag: io_uring-6.7-2023-11-10~38^2~2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=e44679515a7b803cf0143dc9de3d2ecbe907f939;p=linux-2.6-block.git kunit: Fix the wrong kfree of copy for kunit_filter_suites() 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 Reviewed-by: Rae Moar Reviewed-by: David Gow Signed-off-by: Shuah Khan --- 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 @@ free_parsed_glob: free_copy: if (*err) - kfree(copy); + kfree(copy_start); return filtered; }