Re: [PATCH] bug: fix warning suppressions with kunit built as module

From: Nico Pache

Date: Wed Jul 08 2026 - 09:37:06 EST




On 7/7/26 6:58 AM, Bartosz Golaszewski wrote:
> CONFIG_KUNIT is a tristate symbol but the warning suppression code in
> lib/bug.c is only built if it's built-in. Use IS_ENABLE(CONFIG_KUNIT) to
> enable it for a loadable kunit module as well. When using a plain #ifdef,
> the suppressions only work if kunit is built-in.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>

I ran into the same issue and found the following fix also resolved the issue.

Tested-by: Nico Pache <npache@xxxxxxxxxx>
Acked-by: Nico Pache <npache@xxxxxxxxxx>


> ---
> lib/bug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/bug.c b/lib/bug.c
> index 292420f45811..b9820a0226f5 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -219,7 +219,7 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga
> no_cut = bug->flags & BUGFLAG_NO_CUT_HERE;
> has_args = bug->flags & BUGFLAG_ARGS;
>
> -#ifdef CONFIG_KUNIT
> +#if IS_ENABLED(CONFIG_KUNIT)
> /*
> * Before the once logic so suppressed warnings do not consume
> * the single-fire budget of WARN_ON_ONCE().