From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29D71C54E90 for ; Thu, 22 May 2025 14:09:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 78E4010EA65; Thu, 22 May 2025 14:09:54 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4337D10EA65 for ; Thu, 22 May 2025 14:09:52 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 0CC3C45314; Thu, 22 May 2025 14:09:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F182EC4CEE4; Thu, 22 May 2025 14:09:45 +0000 (UTC) Date: Thu, 22 May 2025 15:09:43 +0100 From: Catalin Marinas To: Maxime Ripard Cc: Dave Stevenson , =?iso-8859-1?Q?Ma=EDra?= Canal , Raspberry Pi Kernel Maintenance , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Dmitry Baryshkov , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/vc4: tests: pv_muxing: Fix locking Message-ID: References: <20250520-drm-vc4-kunit-fixes-v1-1-ca281e485f8e@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250520-drm-vc4-kunit-fixes-v1-1-ca281e485f8e@kernel.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 > Closes: https://lore.kernel.org/r/Z_95jWM2YMTGy3pi@arm.com/ > Signed-off-by: Maxime Ripard FWIW, I no longer get the kernel panic: Tested-by: Catalin Marinas