[PATCH] kunit: irq: Unregister on-stack timer and work from debugobjects

0 views
Skip to first unread message

Eric Biggers

unread,
Aug 6, 2026, 1:40:47 AM (10 days ago) Aug 6
to linux-...@vger.kernel.org, linux-...@vger.kernel.org, Ard Biesheuvel, Jason A . Donenfeld, Herbert Xu, kuni...@googlegroups.com, Brendan Higgins, David Gow, Rae Moar, Eric Biggers
In kunit_run_irq_test(), call destroy_hrtimer_on_stack() and
destroy_work_on_stack() to unregister the hrtimer and work from the
debugobjects infrastructure (when CONFIG_DEBUG_OBJECTS_TIMERS=y and
CONFIG_DEBUG_OBJECTS_WORK=y) before the function returns.

Found via code review; the lack of the unregistrations didn't actually
cause a warning, since the objects are inactive upon return anyway. But
they should be there, otherwise debugobjects keeps tracking the objects.

Fixes: 950a81224e8b ("lib/crypto: tests: Add hash-test-template.h and gen-hash-testvecs.py")
Signed-off-by: Eric Biggers <ebig...@kernel.org>
---

This patch is targeting libcrypto-next

include/kunit/run-in-irq-context.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/kunit/run-in-irq-context.h b/include/kunit/run-in-irq-context.h
index 3802b6fb218ed..b46fa1696360c 100644
--- a/include/kunit/run-in-irq-context.h
+++ b/include/kunit/run-in-irq-context.h
@@ -137,6 +137,8 @@ static inline void kunit_run_irq_test(struct kunit *test, bool (*func)(void *),
/* Cancel the timer and work. */
hrtimer_cancel(&state.timer);
flush_work(&state.bh_work);
+ destroy_hrtimer_on_stack(&state.timer);
+ destroy_work_on_stack(&state.bh_work);

/* Sanity check: the timer and BH functions should have been run. */
KUNIT_EXPECT_GT_MSG(test, atomic_read(&state.hardirq_func_calls), 0,

base-commit: 4bceb5614e0fc0338d6787f39df5472bfd72eaab
--
2.55.0

David Gow

unread,
Aug 6, 2026, 7:36:38 AM (10 days ago) Aug 6
to Eric Biggers, linux-...@vger.kernel.org, linux-...@vger.kernel.org, Ard Biesheuvel, Jason A . Donenfeld, Herbert Xu, kuni...@googlegroups.com, Brendan Higgins, Rae Moar
Le 06/08/2026 à 1:38 PM, Eric Biggers a écrit :
> In kunit_run_irq_test(), call destroy_hrtimer_on_stack() and
> destroy_work_on_stack() to unregister the hrtimer and work from the
> debugobjects infrastructure (when CONFIG_DEBUG_OBJECTS_TIMERS=y and
> CONFIG_DEBUG_OBJECTS_WORK=y) before the function returns.
>
> Found via code review; the lack of the unregistrations didn't actually
> cause a warning, since the objects are inactive upon return anyway. But
> they should be there, otherwise debugobjects keeps tracking the objects.
>
> Fixes: 950a81224e8b ("lib/crypto: tests: Add hash-test-template.h and gen-hash-testvecs.py")
> Signed-off-by: Eric Biggers <ebig...@kernel.org>
> ---
>
> This patch is targeting libcrypto-next

Nice catch, thanks!

Reviewed-by: David Gow <da...@davidgow.net>

Cheers,
-- David

Eric Biggers

unread,
Aug 7, 2026, 6:04:37 PM (9 days ago) Aug 7
to linux-...@vger.kernel.org, linux-...@vger.kernel.org, Ard Biesheuvel, Jason A . Donenfeld, Herbert Xu, kuni...@googlegroups.com, Brendan Higgins, David Gow, Rae Moar
On Wed, Aug 05, 2026 at 10:38:04PM -0700, Eric Biggers wrote:
> In kunit_run_irq_test(), call destroy_hrtimer_on_stack() and
> destroy_work_on_stack() to unregister the hrtimer and work from the
> debugobjects infrastructure (when CONFIG_DEBUG_OBJECTS_TIMERS=y and
> CONFIG_DEBUG_OBJECTS_WORK=y) before the function returns.
>
> Found via code review; the lack of the unregistrations didn't actually
> cause a warning, since the objects are inactive upon return anyway. But
> they should be there, otherwise debugobjects keeps tracking the objects.
>
> Fixes: 950a81224e8b ("lib/crypto: tests: Add hash-test-template.h and gen-hash-testvecs.py")
> Signed-off-by: Eric Biggers <ebig...@kernel.org>
> ---
>
> This patch is targeting libcrypto-next

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

- Eric
Reply all
Reply to author
Forward
0 new messages