<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/lib/kunit, branch v6.6.132</title>
<subtitle>Clone of https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git</subtitle>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/'/>
<entry>
<title>kunit: Fix wrong parameter to kunit_deactivate_static_stub()</title>
<updated>2025-06-19T13:28:04+00:00</updated>
<author>
<name>Tzung-Bi Shih</name>
<email>tzungbi@kernel.org</email>
</author>
<published>2025-05-20T08:20:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=f6941e72d352b35babe3cc269eb5a54abf7b8170'/>
<id>f6941e72d352b35babe3cc269eb5a54abf7b8170</id>
<content type='text'>
[ Upstream commit 772e50a76ee664e75581624f512df4e45582605a ]

kunit_deactivate_static_stub() accepts real_fn_addr instead of
replacement_addr.  In the case, it always passes NULL to
kunit_deactivate_static_stub().

Fix it.

Link: https://lore.kernel.org/r/20250520082050.2254875-1-tzungbi@kernel.org
Fixes: e047c5eaa763 ("kunit: Expose 'static stub' API to redirect functions")
Signed-off-by: Tzung-Bi Shih &lt;tzungbi@kernel.org&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 772e50a76ee664e75581624f512df4e45582605a ]

kunit_deactivate_static_stub() accepts real_fn_addr instead of
replacement_addr.  In the case, it always passes NULL to
kunit_deactivate_static_stub().

Fix it.

Link: https://lore.kernel.org/r/20250520082050.2254875-1-tzungbi@kernel.org
Fixes: e047c5eaa763 ("kunit: Expose 'static stub' API to redirect functions")
Signed-off-by: Tzung-Bi Shih &lt;tzungbi@kernel.org&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: Fix timeout message</title>
<updated>2024-07-11T10:49:08+00:00</updated>
<author>
<name>Mickaël Salaün</name>
<email>mic@digikod.net</email>
</author>
<published>2024-04-08T07:46:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=4e40bc50daae8ecf0cc5055c806579f09c31e8d3'/>
<id>4e40bc50daae8ecf0cc5055c806579f09c31e8d3</id>
<content type='text'>
[ Upstream commit 53026ff63bb07c04a0e962a74723eb10ff6f9dc7 ]

The exit code is always checked, so let's properly handle the -ETIMEDOUT
error code.

Cc: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Cc: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Signed-off-by: Mickaël Salaün &lt;mic@digikod.net&gt;
Link: https://lore.kernel.org/r/20240408074625.65017-4-mic@digikod.net
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 53026ff63bb07c04a0e962a74723eb10ff6f9dc7 ]

The exit code is always checked, so let's properly handle the -ETIMEDOUT
error code.

Cc: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Cc: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Signed-off-by: Mickaël Salaün &lt;mic@digikod.net&gt;
Link: https://lore.kernel.org/r/20240408074625.65017-4-mic@digikod.net
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: Fix kthread reference</title>
<updated>2024-06-12T09:11:49+00:00</updated>
<author>
<name>Mickaël Salaün</name>
<email>mic@digikod.net</email>
</author>
<published>2024-04-08T07:46:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=1ec7ccb4cd4b6f72c2998b07880fa7aaf8dfe1d4'/>
<id>1ec7ccb4cd4b6f72c2998b07880fa7aaf8dfe1d4</id>
<content type='text'>
[ Upstream commit f8aa1b98ce40184521ed95ec26cc115a255183b2 ]

There is a race condition when a kthread finishes after the deadline and
before the call to kthread_stop(), which may lead to use after free.

Cc: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Cc: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Fixes: adf505457032 ("kunit: fix UAF when run kfence test case test_gfpzero")
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Signed-off-by: Mickaël Salaün &lt;mic@digikod.net&gt;
Link: https://lore.kernel.org/r/20240408074625.65017-3-mic@digikod.net
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit f8aa1b98ce40184521ed95ec26cc115a255183b2 ]

There is a race condition when a kthread finishes after the deadline and
before the call to kthread_stop(), which may lead to use after free.

Cc: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Cc: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Fixes: adf505457032 ("kunit: fix UAF when run kfence test case test_gfpzero")
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Signed-off-by: Mickaël Salaün &lt;mic@digikod.net&gt;
Link: https://lore.kernel.org/r/20240408074625.65017-3-mic@digikod.net
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: test: Log the correct filter string in executor_test</title>
<updated>2024-03-26T22:19:18+00:00</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2024-02-21T09:27:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=8c018386023b949a23a77ba2cd5c43ee626f4609'/>
<id>8c018386023b949a23a77ba2cd5c43ee626f4609</id>
<content type='text'>
[ Upstream commit 6f2f793fba78eb4a0d5a34a71bc781118ed923d3 ]

KUnit's executor_test logs the filter string in KUNIT_ASSERT_EQ_MSG(),
but passed a random character from the filter, rather than the whole
string.

This was found by annotating KUNIT_ASSERT_EQ_MSG() to let gcc validate
the format string.

Fixes: 76066f93f1df ("kunit: add tests for filtering attributes")
Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Reviewed-by: Justin Stitt &lt;justinstitt@google.com&gt;
Reviewed-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 6f2f793fba78eb4a0d5a34a71bc781118ed923d3 ]

KUnit's executor_test logs the filter string in KUNIT_ASSERT_EQ_MSG(),
but passed a random character from the filter, rather than the whole
string.

This was found by annotating KUNIT_ASSERT_EQ_MSG() to let gcc validate
the format string.

Fixes: 76066f93f1df ("kunit: add tests for filtering attributes")
Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Reviewed-by: Justin Stitt &lt;justinstitt@google.com&gt;
Reviewed-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: run test suites only after module initialization completes</title>
<updated>2024-02-05T20:14:34+00:00</updated>
<author>
<name>Marco Pagani</name>
<email>marpagan@redhat.com</email>
</author>
<published>2024-01-10T15:59:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=8e4319a4e9fdff4af8fea2b587a67970ccc82810'/>
<id>8e4319a4e9fdff4af8fea2b587a67970ccc82810</id>
<content type='text'>
[ Upstream commit a1af6a2bfa0cb46d70b7df5352993e750da6c79b ]

Commit 2810c1e99867 ("kunit: Fix wild-memory-access bug in
kunit_free_suite_set()") fixed a wild-memory-access bug that could have
happened during the loading phase of test suites built and executed as
loadable modules. However, it also introduced a problematic side effect
that causes test suites modules to crash when they attempt to register
fake devices.

When a module is loaded, it traverses the MODULE_STATE_UNFORMED and
MODULE_STATE_COMING states before reaching the normal operating state
MODULE_STATE_LIVE. Finally, when the module is removed, it moves to
MODULE_STATE_GOING before being released. However, if the loading
function load_module() fails between complete_formation() and
do_init_module(), the module goes directly from MODULE_STATE_COMING to
MODULE_STATE_GOING without passing through MODULE_STATE_LIVE.

This behavior was causing kunit_module_exit() to be called without
having first executed kunit_module_init(). Since kunit_module_exit() is
responsible for freeing the memory allocated by kunit_module_init()
through kunit_filter_suites(), this behavior was resulting in a
wild-memory-access bug.

Commit 2810c1e99867 ("kunit: Fix wild-memory-access bug in
kunit_free_suite_set()") fixed this issue by running the tests when the
module is still in MODULE_STATE_COMING. However, modules in that state
are not fully initialized, lacking sysfs kobjects. Therefore, if a test
module attempts to register a fake device, it will inevitably crash.

This patch proposes a different approach to fix the original
wild-memory-access bug while restoring the normal module execution flow
by making kunit_module_exit() able to detect if kunit_module_init() has
previously initialized the tests suite set. In this way, test modules
can once again register fake devices without crashing.

This behavior is achieved by checking whether mod-&gt;kunit_suites is a
virtual or direct mapping address. If it is a virtual address, then
kunit_module_init() has allocated the suite_set in kunit_filter_suites()
using kmalloc_array(). On the contrary, if mod-&gt;kunit_suites is still
pointing to the original address that was set when looking up the
.kunit_test_suites section of the module, then the loading phase has
failed and there's no memory to be freed.

v4:
- rebased on 6.8
- noted that kunit_filter_suites() must return a virtual address
v3:
- add a comment to clarify why the start address is checked
v2:
- add include &lt;linux/mm.h&gt;

Fixes: 2810c1e99867 ("kunit: Fix wild-memory-access bug in kunit_free_suite_set()")
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Tested-by: Rae Moar &lt;rmoar@google.com&gt;
Tested-by: Richard Fitzgerald &lt;rf@opensource.cirrus.com&gt;
Reviewed-by: Javier Martinez Canillas &lt;javierm@redhat.com&gt;
Signed-off-by: Marco Pagani &lt;marpagan@redhat.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit a1af6a2bfa0cb46d70b7df5352993e750da6c79b ]

Commit 2810c1e99867 ("kunit: Fix wild-memory-access bug in
kunit_free_suite_set()") fixed a wild-memory-access bug that could have
happened during the loading phase of test suites built and executed as
loadable modules. However, it also introduced a problematic side effect
that causes test suites modules to crash when they attempt to register
fake devices.

When a module is loaded, it traverses the MODULE_STATE_UNFORMED and
MODULE_STATE_COMING states before reaching the normal operating state
MODULE_STATE_LIVE. Finally, when the module is removed, it moves to
MODULE_STATE_GOING before being released. However, if the loading
function load_module() fails between complete_formation() and
do_init_module(), the module goes directly from MODULE_STATE_COMING to
MODULE_STATE_GOING without passing through MODULE_STATE_LIVE.

This behavior was causing kunit_module_exit() to be called without
having first executed kunit_module_init(). Since kunit_module_exit() is
responsible for freeing the memory allocated by kunit_module_init()
through kunit_filter_suites(), this behavior was resulting in a
wild-memory-access bug.

Commit 2810c1e99867 ("kunit: Fix wild-memory-access bug in
kunit_free_suite_set()") fixed this issue by running the tests when the
module is still in MODULE_STATE_COMING. However, modules in that state
are not fully initialized, lacking sysfs kobjects. Therefore, if a test
module attempts to register a fake device, it will inevitably crash.

This patch proposes a different approach to fix the original
wild-memory-access bug while restoring the normal module execution flow
by making kunit_module_exit() able to detect if kunit_module_init() has
previously initialized the tests suite set. In this way, test modules
can once again register fake devices without crashing.

This behavior is achieved by checking whether mod-&gt;kunit_suites is a
virtual or direct mapping address. If it is a virtual address, then
kunit_module_init() has allocated the suite_set in kunit_filter_suites()
using kmalloc_array(). On the contrary, if mod-&gt;kunit_suites is still
pointing to the original address that was set when looking up the
.kunit_test_suites section of the module, then the loading phase has
failed and there's no memory to be freed.

v4:
- rebased on 6.8
- noted that kunit_filter_suites() must return a virtual address
v3:
- add a comment to clarify why the start address is checked
v2:
- add include &lt;linux/mm.h&gt;

Fixes: 2810c1e99867 ("kunit: Fix wild-memory-access bug in kunit_free_suite_set()")
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Tested-by: Rae Moar &lt;rmoar@google.com&gt;
Tested-by: Richard Fitzgerald &lt;rf@opensource.cirrus.com&gt;
Reviewed-by: Javier Martinez Canillas &lt;javierm@redhat.com&gt;
Signed-off-by: Marco Pagani &lt;marpagan@redhat.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: debugfs: Fix unchecked dereference in debugfs_print_results()</title>
<updated>2024-01-25T23:35:15+00:00</updated>
<author>
<name>Richard Fitzgerald</name>
<email>rf@opensource.cirrus.com</email>
</author>
<published>2023-10-30T10:47:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=5e990887803420f2d50b510bd1203d66ecb7d40a'/>
<id>5e990887803420f2d50b510bd1203d66ecb7d40a</id>
<content type='text'>
[ Upstream commit 34dfd5bb2e5507e69d9b6d6c90f546600c7a4977 ]

Move the call to kunit_suite_has_succeeded() after the check that
the kunit_suite pointer is valid.

This was found by smatch:

 lib/kunit/debugfs.c:66 debugfs_print_results() warn: variable
 dereferenced before check 'suite' (see line 63)

Signed-off-by: Richard Fitzgerald &lt;rf@opensource.cirrus.com&gt;
Reported-by: Dan Carpenter &lt;dan.carpenter@linaro.org&gt;
Fixes: 38289a26e1b8 ("kunit: fix debugfs code to use enum kunit_status, not bool")
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 34dfd5bb2e5507e69d9b6d6c90f546600c7a4977 ]

Move the call to kunit_suite_has_succeeded() after the check that
the kunit_suite pointer is valid.

This was found by smatch:

 lib/kunit/debugfs.c:66 debugfs_print_results() warn: variable
 dereferenced before check 'suite' (see line 63)

Signed-off-by: Richard Fitzgerald &lt;rf@opensource.cirrus.com&gt;
Reported-by: Dan Carpenter &lt;dan.carpenter@linaro.org&gt;
Fixes: 38289a26e1b8 ("kunit: fix debugfs code to use enum kunit_status, not bool")
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: Reset suite counter right before running tests</title>
<updated>2024-01-20T10:51:37+00:00</updated>
<author>
<name>Michal Wajdeczko</name>
<email>michal.wajdeczko@intel.com</email>
</author>
<published>2023-10-04T20:57:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=b12a331178d4c7dcc3d1a2323f86f5de33c5ba9c'/>
<id>b12a331178d4c7dcc3d1a2323f86f5de33c5ba9c</id>
<content type='text'>
[ Upstream commit 2e3c94aed51eabbe9c1c0ee515371ea5441c2fa7 ]

Today we reset the suite counter as part of the suite cleanup,
called from the module exit callback, but it might not work that
well as one can try to collect results without unloading a previous
test (either unintentionally or due to dependencies).

For easy reproduction try to load the kunit-test.ko and then
collect and parse results from the kunit-example-test.ko load.
Parser will complain about mismatch of expected test number:

[ ] KTAP version 1
[ ] 1..1
[ ]     # example: initializing suite
[ ]     KTAP version 1
[ ]     # Subtest: example
..
[ ] # example: pass:5 fail:0 skip:4 total:9
[ ] # Totals: pass:6 fail:0 skip:6 total:12
[ ] ok 7 example

[ ] [ERROR] Test: example: Expected test number 1 but found 7
[ ] ===================== [PASSED] example =====================
[ ] ============================================================
[ ] Testing complete. Ran 12 tests: passed: 6, skipped: 6, errors: 1

Since we are now printing suite test plan on every module load,
right before running suite tests, we should make sure that suite
counter will also start from 1. Easiest solution seems to be move
counter reset to the __kunit_test_suites_init() function.

Signed-off-by: Michal Wajdeczko &lt;michal.wajdeczko@intel.com&gt;
Cc: David Gow &lt;davidgow@google.com&gt;
Cc: Rae Moar &lt;rmoar@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 2e3c94aed51eabbe9c1c0ee515371ea5441c2fa7 ]

Today we reset the suite counter as part of the suite cleanup,
called from the module exit callback, but it might not work that
well as one can try to collect results without unloading a previous
test (either unintentionally or due to dependencies).

For easy reproduction try to load the kunit-test.ko and then
collect and parse results from the kunit-example-test.ko load.
Parser will complain about mismatch of expected test number:

[ ] KTAP version 1
[ ] 1..1
[ ]     # example: initializing suite
[ ]     KTAP version 1
[ ]     # Subtest: example
..
[ ] # example: pass:5 fail:0 skip:4 total:9
[ ] # Totals: pass:6 fail:0 skip:6 total:12
[ ] ok 7 example

[ ] [ERROR] Test: example: Expected test number 1 but found 7
[ ] ===================== [PASSED] example =====================
[ ] ============================================================
[ ] Testing complete. Ran 12 tests: passed: 6, skipped: 6, errors: 1

Since we are now printing suite test plan on every module load,
right before running suite tests, we should make sure that suite
counter will also start from 1. Easiest solution seems to be move
counter reset to the __kunit_test_suites_init() function.

Signed-off-by: Michal Wajdeczko &lt;michal.wajdeczko@intel.com&gt;
Cc: David Gow &lt;davidgow@google.com&gt;
Cc: Rae Moar &lt;rmoar@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: Warn if tests are slow</title>
<updated>2024-01-20T10:51:37+00:00</updated>
<author>
<name>Maxime Ripard</name>
<email>mripard@kernel.org</email>
</author>
<published>2023-10-26T08:59:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=858c0840ef02e9f49dba3860a6c6d06d181de43d'/>
<id>858c0840ef02e9f49dba3860a6c6d06d181de43d</id>
<content type='text'>
[ Upstream commit f8f2847f739dc899d0e563eac01299dadefa64ff ]

Kunit recently gained support to setup attributes, the first one being
the speed of a given test, then allowing to filter out slow tests.

A slow test is defined in the documentation as taking more than one
second. There's an another speed attribute called "super slow" but whose
definition is less clear.

Add support to the test runner to check the test execution time, and
report tests that should be marked as slow but aren't.

Signed-off-by: Maxime Ripard &lt;mripard@kernel.org&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit f8f2847f739dc899d0e563eac01299dadefa64ff ]

Kunit recently gained support to setup attributes, the first one being
the speed of a given test, then allowing to filter out slow tests.

A slow test is defined in the documentation as taking more than one
second. There's an another speed attribute called "super slow" but whose
definition is less clear.

Add support to the test runner to check the test execution time, and
report tests that should be marked as slow but aren't.

Signed-off-by: Maxime Ripard &lt;mripard@kernel.org&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: test: Fix the possible memory leak in executor_test</title>
<updated>2023-11-20T10:59:15+00:00</updated>
<author>
<name>Jinjie Ruan</name>
<email>ruanjinjie@huawei.com</email>
</author>
<published>2023-09-27T09:03:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=a2431a39590f2ce2d68109458f3fa3f49a6e3534'/>
<id>a2431a39590f2ce2d68109458f3fa3f49a6e3534</id>
<content type='text'>
[ Upstream commit 8040345fdae4cb256c5d981f91ae0f22bea8adcc ]

When CONFIG_KUNIT_ALL_TESTS=y, making CONFIG_DEBUG_KMEMLEAK=y and
CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y, the below memory leak is detected.

If kunit_filter_suites() succeeds, not only copy but also filtered_suite
and filtered_suite-&gt;test_cases should be freed.

So as Rae suggested, to avoid the suite set never be freed when
KUNIT_ASSERT_EQ() fails and exits after kunit_filter_suites() succeeds,
update kfree_at_end() func to free_suite_set_at_end() to use
kunit_free_suite_set() to free them as kunit_module_exit() and
kunit_run_all_tests() do it. As the second arg got of
free_suite_set_at_end() is a local variable, copy it for free to avoid
wild-memory-access. After applying this patch, the following memory leak
is never detected.

unreferenced object 0xffff8881001de400 (size 1024):
  comm "kunit_try_catch", pid 1396, jiffies 4294720452 (age 932.801s)
  hex dump (first 32 bytes):
    73 75 69 74 65 32 00 00 00 00 00 00 00 00 00 00  suite2..........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817db753&gt;] __kmalloc_node_track_caller+0x53/0x150
    [&lt;ffffffff817bd242&gt;] kmemdup+0x22/0x50
    [&lt;ffffffff829e961d&gt;] kunit_filter_suites+0x44d/0xcc0
    [&lt;ffffffff829eb69f&gt;] filter_suites_test+0x12f/0x360
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff8881052cd388 (size 192):
  comm "kunit_try_catch", pid 1396, jiffies 4294720452 (age 932.801s)
  hex dump (first 32 bytes):
    a0 85 9e 82 ff ff ff ff 80 cd 7c 84 ff ff ff ff  ..........|.....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817dbad2&gt;] __kmalloc+0x52/0x150
    [&lt;ffffffff829e9651&gt;] kunit_filter_suites+0x481/0xcc0
    [&lt;ffffffff829eb69f&gt;] filter_suites_test+0x12f/0x360
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20

unreferenced object 0xffff888100da8400 (size 1024):
  comm "kunit_try_catch", pid 1398, jiffies 4294720454 (age 781.945s)
  hex dump (first 32 bytes):
    73 75 69 74 65 32 00 00 00 00 00 00 00 00 00 00  suite2..........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817db753&gt;] __kmalloc_node_track_caller+0x53/0x150
    [&lt;ffffffff817bd242&gt;] kmemdup+0x22/0x50
    [&lt;ffffffff829e961d&gt;] kunit_filter_suites+0x44d/0xcc0
    [&lt;ffffffff829eb13f&gt;] filter_suites_test_glob_test+0x12f/0x560
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff888105117878 (size 96):
  comm "kunit_try_catch", pid 1398, jiffies 4294720454 (age 781.945s)
  hex dump (first 32 bytes):
    a0 85 9e 82 ff ff ff ff a0 ac 7c 84 ff ff ff ff  ..........|.....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817dbad2&gt;] __kmalloc+0x52/0x150
    [&lt;ffffffff829e9651&gt;] kunit_filter_suites+0x481/0xcc0
    [&lt;ffffffff829eb13f&gt;] filter_suites_test_glob_test+0x12f/0x560
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff888102c31c00 (size 1024):
  comm "kunit_try_catch", pid 1404, jiffies 4294720460 (age 781.948s)
  hex dump (first 32 bytes):
    6e 6f 72 6d 61 6c 5f 73 75 69 74 65 00 00 00 00  normal_suite....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817db753&gt;] __kmalloc_node_track_caller+0x53/0x150
    [&lt;ffffffff817bd242&gt;] kmemdup+0x22/0x50
    [&lt;ffffffff829ecf17&gt;] kunit_filter_attr_tests+0xf7/0x860
    [&lt;ffffffff829e99ff&gt;] kunit_filter_suites+0x82f/0xcc0
    [&lt;ffffffff829ea975&gt;] filter_attr_test+0x195/0x5f0
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff8881052cd250 (size 192):
  comm "kunit_try_catch", pid 1404, jiffies 4294720460 (age 781.948s)
  hex dump (first 32 bytes):
    a0 85 9e 82 ff ff ff ff 00 a9 7c 84 ff ff ff ff  ..........|.....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817dbad2&gt;] __kmalloc+0x52/0x150
    [&lt;ffffffff829ecfc1&gt;] kunit_filter_attr_tests+0x1a1/0x860
    [&lt;ffffffff829e99ff&gt;] kunit_filter_suites+0x82f/0xcc0
    [&lt;ffffffff829ea975&gt;] filter_attr_test+0x195/0x5f0
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff888104f4e400 (size 1024):
  comm "kunit_try_catch", pid 1408, jiffies 4294720464 (age 781.944s)
  hex dump (first 32 bytes):
    73 75 69 74 65 00 00 00 00 00 00 00 00 00 00 00  suite...........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817db753&gt;] __kmalloc_node_track_caller+0x53/0x150
    [&lt;ffffffff817bd242&gt;] kmemdup+0x22/0x50
    [&lt;ffffffff829ecf17&gt;] kunit_filter_attr_tests+0xf7/0x860
    [&lt;ffffffff829e99ff&gt;] kunit_filter_suites+0x82f/0xcc0
    [&lt;ffffffff829e9fc3&gt;] filter_attr_skip_test+0x133/0x6e0
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff8881052cc620 (size 192):
  comm "kunit_try_catch", pid 1408, jiffies 4294720464 (age 781.944s)
  hex dump (first 32 bytes):
    a0 85 9e 82 ff ff ff ff c0 a8 7c 84 ff ff ff ff  ..........|.....
    00 00 00 00 00 00 00 00 02 00 00 00 02 00 00 00  ................
  backtrace:
    [&lt;ffffffff817dbad2&gt;] __kmalloc+0x52/0x150
    [&lt;ffffffff829ecfc1&gt;] kunit_filter_attr_tests+0x1a1/0x860
    [&lt;ffffffff829e99ff&gt;] kunit_filter_suites+0x82f/0xcc0
    [&lt;ffffffff829e9fc3&gt;] filter_attr_skip_test+0x133/0x6e0
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20

Fixes: e5857d396f35 ("kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites")
Fixes: 76066f93f1df ("kunit: add tests for filtering attributes")
Signed-off-by: Jinjie Ruan &lt;ruanjinjie@huawei.com&gt;
Suggested-by: Rae Moar &lt;rmoar@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Suggested-by: David Gow &lt;davidgow@google.com&gt;
Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Closes: https://lore.kernel.org/oe-kbuild-all/202309142251.uJ8saAZv-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202309270433.wGmFRGjd-lkp@intel.com/
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 8040345fdae4cb256c5d981f91ae0f22bea8adcc ]

When CONFIG_KUNIT_ALL_TESTS=y, making CONFIG_DEBUG_KMEMLEAK=y and
CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y, the below memory leak is detected.

If kunit_filter_suites() succeeds, not only copy but also filtered_suite
and filtered_suite-&gt;test_cases should be freed.

So as Rae suggested, to avoid the suite set never be freed when
KUNIT_ASSERT_EQ() fails and exits after kunit_filter_suites() succeeds,
update kfree_at_end() func to free_suite_set_at_end() to use
kunit_free_suite_set() to free them as kunit_module_exit() and
kunit_run_all_tests() do it. As the second arg got of
free_suite_set_at_end() is a local variable, copy it for free to avoid
wild-memory-access. After applying this patch, the following memory leak
is never detected.

unreferenced object 0xffff8881001de400 (size 1024):
  comm "kunit_try_catch", pid 1396, jiffies 4294720452 (age 932.801s)
  hex dump (first 32 bytes):
    73 75 69 74 65 32 00 00 00 00 00 00 00 00 00 00  suite2..........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817db753&gt;] __kmalloc_node_track_caller+0x53/0x150
    [&lt;ffffffff817bd242&gt;] kmemdup+0x22/0x50
    [&lt;ffffffff829e961d&gt;] kunit_filter_suites+0x44d/0xcc0
    [&lt;ffffffff829eb69f&gt;] filter_suites_test+0x12f/0x360
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff8881052cd388 (size 192):
  comm "kunit_try_catch", pid 1396, jiffies 4294720452 (age 932.801s)
  hex dump (first 32 bytes):
    a0 85 9e 82 ff ff ff ff 80 cd 7c 84 ff ff ff ff  ..........|.....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817dbad2&gt;] __kmalloc+0x52/0x150
    [&lt;ffffffff829e9651&gt;] kunit_filter_suites+0x481/0xcc0
    [&lt;ffffffff829eb69f&gt;] filter_suites_test+0x12f/0x360
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20

unreferenced object 0xffff888100da8400 (size 1024):
  comm "kunit_try_catch", pid 1398, jiffies 4294720454 (age 781.945s)
  hex dump (first 32 bytes):
    73 75 69 74 65 32 00 00 00 00 00 00 00 00 00 00  suite2..........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817db753&gt;] __kmalloc_node_track_caller+0x53/0x150
    [&lt;ffffffff817bd242&gt;] kmemdup+0x22/0x50
    [&lt;ffffffff829e961d&gt;] kunit_filter_suites+0x44d/0xcc0
    [&lt;ffffffff829eb13f&gt;] filter_suites_test_glob_test+0x12f/0x560
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff888105117878 (size 96):
  comm "kunit_try_catch", pid 1398, jiffies 4294720454 (age 781.945s)
  hex dump (first 32 bytes):
    a0 85 9e 82 ff ff ff ff a0 ac 7c 84 ff ff ff ff  ..........|.....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817dbad2&gt;] __kmalloc+0x52/0x150
    [&lt;ffffffff829e9651&gt;] kunit_filter_suites+0x481/0xcc0
    [&lt;ffffffff829eb13f&gt;] filter_suites_test_glob_test+0x12f/0x560
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff888102c31c00 (size 1024):
  comm "kunit_try_catch", pid 1404, jiffies 4294720460 (age 781.948s)
  hex dump (first 32 bytes):
    6e 6f 72 6d 61 6c 5f 73 75 69 74 65 00 00 00 00  normal_suite....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817db753&gt;] __kmalloc_node_track_caller+0x53/0x150
    [&lt;ffffffff817bd242&gt;] kmemdup+0x22/0x50
    [&lt;ffffffff829ecf17&gt;] kunit_filter_attr_tests+0xf7/0x860
    [&lt;ffffffff829e99ff&gt;] kunit_filter_suites+0x82f/0xcc0
    [&lt;ffffffff829ea975&gt;] filter_attr_test+0x195/0x5f0
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff8881052cd250 (size 192):
  comm "kunit_try_catch", pid 1404, jiffies 4294720460 (age 781.948s)
  hex dump (first 32 bytes):
    a0 85 9e 82 ff ff ff ff 00 a9 7c 84 ff ff ff ff  ..........|.....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817dbad2&gt;] __kmalloc+0x52/0x150
    [&lt;ffffffff829ecfc1&gt;] kunit_filter_attr_tests+0x1a1/0x860
    [&lt;ffffffff829e99ff&gt;] kunit_filter_suites+0x82f/0xcc0
    [&lt;ffffffff829ea975&gt;] filter_attr_test+0x195/0x5f0
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff888104f4e400 (size 1024):
  comm "kunit_try_catch", pid 1408, jiffies 4294720464 (age 781.944s)
  hex dump (first 32 bytes):
    73 75 69 74 65 00 00 00 00 00 00 00 00 00 00 00  suite...........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff817db753&gt;] __kmalloc_node_track_caller+0x53/0x150
    [&lt;ffffffff817bd242&gt;] kmemdup+0x22/0x50
    [&lt;ffffffff829ecf17&gt;] kunit_filter_attr_tests+0xf7/0x860
    [&lt;ffffffff829e99ff&gt;] kunit_filter_suites+0x82f/0xcc0
    [&lt;ffffffff829e9fc3&gt;] filter_attr_skip_test+0x133/0x6e0
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20
unreferenced object 0xffff8881052cc620 (size 192):
  comm "kunit_try_catch", pid 1408, jiffies 4294720464 (age 781.944s)
  hex dump (first 32 bytes):
    a0 85 9e 82 ff ff ff ff c0 a8 7c 84 ff ff ff ff  ..........|.....
    00 00 00 00 00 00 00 00 02 00 00 00 02 00 00 00  ................
  backtrace:
    [&lt;ffffffff817dbad2&gt;] __kmalloc+0x52/0x150
    [&lt;ffffffff829ecfc1&gt;] kunit_filter_attr_tests+0x1a1/0x860
    [&lt;ffffffff829e99ff&gt;] kunit_filter_suites+0x82f/0xcc0
    [&lt;ffffffff829e9fc3&gt;] filter_attr_skip_test+0x133/0x6e0
    [&lt;ffffffff829e802a&gt;] kunit_generic_run_threadfn_adapter+0x4a/0x90
    [&lt;ffffffff81236fc6&gt;] kthread+0x2b6/0x380
    [&lt;ffffffff81096afd&gt;] ret_from_fork+0x2d/0x70
    [&lt;ffffffff81003511&gt;] ret_from_fork_asm+0x11/0x20

Fixes: e5857d396f35 ("kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites")
Fixes: 76066f93f1df ("kunit: add tests for filtering attributes")
Signed-off-by: Jinjie Ruan &lt;ruanjinjie@huawei.com&gt;
Suggested-by: Rae Moar &lt;rmoar@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Suggested-by: David Gow &lt;davidgow@google.com&gt;
Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Closes: https://lore.kernel.org/oe-kbuild-all/202309142251.uJ8saAZv-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202309270433.wGmFRGjd-lkp@intel.com/
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kunit: Fix possible memory leak in kunit_filter_suites()</title>
<updated>2023-11-20T10:59:15+00:00</updated>
<author>
<name>Jinjie Ruan</name>
<email>ruanjinjie@huawei.com</email>
</author>
<published>2023-09-27T09:03:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=71edfc95113890ef872544c947b1f113519da8f4'/>
<id>71edfc95113890ef872544c947b1f113519da8f4</id>
<content type='text'>
[ Upstream commit 24de14c98b37ea40a7e493dfd0d93b400b6efbca ]

If the outer layer for loop is iterated more than once and it fails not
in the first iteration, the filtered_suite and filtered_suite-&gt;test_cases
allocated in the last kunit_filter_attr_tests() in last inner for loop
is leaked.

So add a new free_filtered_suite err label and free the filtered_suite
and filtered_suite-&gt;test_cases so far. And change kmalloc_array of copy
to kcalloc to Clear the copy to make the kfree safe.

Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes")
Signed-off-by: Jinjie Ruan &lt;ruanjinjie@huawei.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 24de14c98b37ea40a7e493dfd0d93b400b6efbca ]

If the outer layer for loop is iterated more than once and it fails not
in the first iteration, the filtered_suite and filtered_suite-&gt;test_cases
allocated in the last kunit_filter_attr_tests() in last inner for loop
is leaked.

So add a new free_filtered_suite err label and free the filtered_suite
and filtered_suite-&gt;test_cases so far. And change kmalloc_array of copy
to kcalloc to Clear the copy to make the kfree safe.

Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes")
Signed-off-by: Jinjie Ruan &lt;ruanjinjie@huawei.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
