linux-stable/lib/kunit
David Gow a8a7e3ced3 kunit: executor: Fix a memory leak on failure in kunit_filter_tests
[ Upstream commit 94681e289b ]

It's possible that memory allocation for 'filtered' will fail, but for the
copy of the suite to succeed. In this case, the copy could be leaked.

Properly free 'copy' in the error case for the allocation of 'filtered'
failing.

Note that there may also have been a similar issue in
kunit_filter_subsuites, before it was removed in "kunit: flatten
kunit_suite*** to kunit_suite** in .kunit_test_suites".

This was reported by clang-analyzer via the kernel test robot, here:
https://lore.kernel.org/all/c8073b8e-7b9e-0830-4177-87c12f16349c@intel.com/

And by smatch via Dan Carpenter and the kernel test robot:
https://lore.kernel.org/all/202207101328.ASjx88yj-lkp@intel.com/

Fixes: a02353f491 ("kunit: bail out of test filtering logic quicker if OOM")
Reported-by: kernel test robot <yujie.liu@intel.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-17 14:41:05 +02:00
..
.kunitconfig kunit: tool: make --kunitconfig accept dirs, add lib/kunit fragment 2021-04-02 14:14:36 -06:00
Kconfig kunit: add kunit.filter_glob cmdline option to filter suites 2021-02-08 16:09:27 -07:00
Makefile kunit: test: create a single centralized executor for all tests 2020-10-09 14:37:34 -06:00
assert.c kunit: factor out str constants from binary assertion structs 2022-01-31 11:55:39 -07:00
debugfs.c kunit: fix debugfs code to use enum kunit_status, not bool 2022-06-09 10:30:05 +02:00
debugfs.h kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display 2020-03-26 14:07:18 -06:00
executor.c kunit: executor: Fix a memory leak on failure in kunit_filter_tests 2022-08-17 14:41:05 +02:00
executor_test.c kunit: bail out of test filtering logic quicker if OOM 2022-06-09 10:29:42 +02:00
kunit-example-test.c kunit: add example test case showing off all the expect macros 2022-01-25 12:49:20 -07:00
kunit-test.c kunit: drop assumption in kunit-log-test about current suite 2021-10-19 14:18:49 -06:00
string-stream-test.c kunit: allow kunit tests to be loaded as a module 2020-01-09 16:42:29 -07:00
string-stream.c kunit: generalize kunit_resource API beyond allocated resources 2020-06-26 14:12:00 -06:00
string-stream.h isystem: ship and use stdarg.h 2021-08-19 09:02:55 +09:00
test.c kunit: remove va_format from kunit_assert 2022-01-31 11:55:27 -07:00
try-catch-impl.h kunit: hide unexported try-catch interface in try-catch-impl.h 2020-01-09 16:42:09 -07:00
try-catch.c kunit: make kunit_test_timeout compatible with comment 2022-03-22 15:57:11 -07:00