On Tue, May 20, 2025 at 02:08:36PM +0200, Maxime Ripard wrote: > Commit 30188df0c387 ("drm/tests: Drop drm_kunit_helper_acquire_ctx_alloc()") > removed a kunit-managed function to get a drm_modeset_acquire_ctx. > > It converted the vc4_pv_muxing_test_init() function, used by > drm_vc4_test_pv_muxing() and drm_vc4_test_pv_muxing_invalid(). However, > during that conversion, it went from being kzalloc'd to being allocated > on the stack. > > vc4_pv_muxing_test_init() then uses that context to allocate a > drm_atomic_state using drm_kunit_helper_atomic_state_alloc(), which > stores a pointer to the locking context in the allocated state. > > However, since vc4_pv_muxing_test_init() is a test init function, the > context is then cleared when we leave the function, and before executing > the test. We're then running the test with a dangling pointer, which > then leads to various crashes. > > Rework the context initialization and state allocation to move them to > drm_vc4_test_pv_muxing() and drm_vc4_test_pv_muxing_invalid(). > > Fixes: 30188df0c387 ("drm/tests: Drop drm_kunit_helper_acquire_ctx_alloc()") > Reported-by: Catalin Marinas <catalin.mari...@arm.com> > Closes: https://lore.kernel.org/r/z_95jwm2ymtgy...@arm.com/ > Signed-off-by: Maxime Ripard <mrip...@kernel.org>
FWIW, I no longer get the kernel panic: Tested-by: Catalin Marinas <catalin.mari...@arm.com>