From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A76673E172D for ; Mon, 24 Aug 2026 06:52:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787554368; cv=none; b=M+Id+pHDIDQA9Cy4pbxvsByy5m68NHTNpusdI1jUtW3ZZId3/F/4sC2RmwIp1ZLSFLUm7eVqhMD07zijdpYZURaw8J3u3JcWVE5W3xMdgyy2DsygdSlrTV6qow9BPlKK5UwQyilzQv2pbMNB9vyHR9c4dAnyYXvroISS/naTFAE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787554368; c=relaxed/simple; bh=M4xvN+XvUqVrakj7qRWgDRpy8v9wprtFB1RvzhjKo4E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X3dw+/+ySjbWA4C1h0ai/ecW7JK3HW5gXlbyT/bZOWHWcAosA0RmOvtptoQ5JjiQqy2xSqhwYXgIA9bMVgv0Lha5qFMu0yDODxSoKFSZwzit/qGlSJkbVkPoSsJf6mLXpa6sImhYRx+7baWytXxqmKG4Sy009wW+JP4Pto6SiGo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GGBJEDOv; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GGBJEDOv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAE331F000E9; Mon, 24 Aug 2026 06:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787554367; bh=wlrAFaWo1E9hyYaIgSD0+VLQ53/AVaiGp6wMA6KTVQQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=GGBJEDOvUmxuTCp2AtIBaxsqKLHu8hHDITDP6CLMYM9AxLYKVVeQtoSwOKDysH0PL Zxw2sdSlLeST40HBUmI4OV9A1yoG/G1Pw/Q6FU4iIQidFARbWdUT3Js1nfmLTXCjVA Uax2++0S1FvsuGbOtbOzoGZD18g2YIWOdB6AOtI206Tb8MT16KSbzYwMvt4jqcasW9 UYcG3TAFR2LuNw2fDxkguLUd/kSG3HK/WTaReuSCtydQFOEGvF2aLV2HmJA+l7QxJK XymUDYSBuQKMbAUWlYrNg/tUDOReWReIIXGbPHxE188rFeVofj/QVTDmipf5HaDwDd oBa8izaSr34ZA== Date: Mon, 24 Aug 2026 08:52:44 +0200 From: Maxime Ripard To: Karl Mehltretter Cc: Dave Stevenson , =?utf-8?B?TWHDrXJh?= Canal , Raspberry Pi Kernel Maintenance , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/vc4: hdmi: Unregister the ASoC card on unbind Message-ID: <20260824-expert-sepia-oyster-cabaea@houat> References: <20260822143218.68764-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha384; protocol="application/pgp-signature"; boundary="2nw3szy5zgrinfwp" Content-Disposition: inline In-Reply-To: <20260822143218.68764-1-kmehltretter@gmail.com> --2nw3szy5zgrinfwp Content-Type: text/plain; protected-headers=v1; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] drm/vc4: hdmi: Unregister the ASoC card on unbind MIME-Version: 1.0 On Sat, Aug 22, 2026 at 04:32:18PM +0200, Karl Mehltretter wrote: > vc4_hdmi, including the embedded ASoC card, is DRM-managed and freed > together with the DRM device when the aggregate device is torn down. > The card however is registered device-managed on the HDMI platform > device, whose release runs later Not necessarily, no. The comment you removed explained it. DRM-managed memory isn't removed when the device in unbound/removed, but when it has been and the last fd to the device file has been closed to userspace. > so snd_soc_unregister_card() operates on freed memory: >=20 > # modprobe vc4; rmmod vc4 > BUG: KASAN: slab-use-after-free in snd_soc_unregister_card > Read of size 1 at addr ffff0000456a8450 by task rmmod/262 > Allocated by task 171: drmm_kmalloc / vc4_hdmi_bind > Freed by task 262 (rmmod): drm_managed_release / drm_dev_put And that happens only because you have no user. If you had one, you would have had the opposite sequence. Maxime --2nw3szy5zgrinfwp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iJUEABMJAB0WIQTkHFbLp4ejekA/qfgnX84Zoj2+dgUCaovqPAAKCRAnX84Zoj2+ dhrDAYCAAsWCltPgMB7RSFCkdIfB7+hLSVCZswgsYNWF23+uWuFaTfNfleRm72Uq cWeXnIgBfAidP/BhAf7UGp2w0J6CGKFP9iImXy/uXGXIyoQNabPxoJ/s5HruRE4H a2YO1+CL8A== =NpUy -----END PGP SIGNATURE----- --2nw3szy5zgrinfwp--