Re: [PATCH next] kunit: Initialize filter error before disabled cleanup

From: Thomas Weißschuh

Date: Fri Sep 25 2026 - 03:48:03 EST


On Mon, Sep 14, 2026 at 04:59:33AM +0200, Karl Mehltretter wrote:
> kunit_run_all_tests() jumps to free_out when KUnit execution is disabled.
> If a boot filter is configured, free_out tests err even though
> kunit_filter_suites() was never called to initialize it.
>
> Clang's -Wconditional-uninitialized diagnoses this path. KMSAN confirms
> the runtime use.
>
> With CONFIG_KUNIT_DEFAULT_ENABLED=n,
> CONFIG_KUNIT_DEFAULT_FILTER_GLOB="*", CONFIG_INIT_STACK_NONE=y and
> CONFIG_KMSAN=y, KMSAN reports an uninitialized-value use in
> kunit_run_all_tests() and identifies local variable err as its origin.
>
> Restore the zero initializer. It remains necessary as cleanup state after
> kunit_run_all_tests() was changed to return void.
>
> Fixes: e38f53f04824 ("kunit: Return void from kunit_run_all_tests()")
> Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>

Thanks!

Reviewed-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>

The code using the variable was not yet there when I wrote the patch.
Also this logic could really use some cleanup...

> ---
> lib/kunit/executor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

(...)