From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796325821; b=cHSHK0fvKiO2roxM2nDe/vMI5HeRVAdkLPhvMjQiDhu7fP6wz2cguAIdjzQlusg+qJyN KHr4Esl9seDILkGYHHPNFC3E2pBz5XNOOXFREEa7aN7bb9tbKe2EuhQ92Npxwioivzs1d riqzhNWt5l4CRF7nNWYQJdhZnxSvMoquzNNHWPe7Xec9hfUXrUkch1dNUam+gR/U4feAz B8knsbXYAv6/Ydh/m2T10jpvC7edGk+NQyMen9C0gVv6C8D+jHE8wm+ycFpJ/ALZem/o5 eScQIxWjHY+dPMHI3r86Fqy5B5iaejSoG5CxGxYdZXha18BzxxtZn2K3Lsh8gNp89aA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796325821; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=SdBcA5aLZMxYz1XZLXO9CP0VkidoDsaz82ZQ4lq18Q4=; b=mTnrvaGVEYW7R3G5zG4Smicszamx+fxS+wE+SAvbNvnms9bvsEOdKNmeoTiY1XHlXQi6 NHiXfDyeg8Mv+RhYo/npLGOu6hTlsNPmgwu5EMzet2AQ/ntGXqLXjLQY1OtMDrk1ZO82l +e44yiRoLiARWgiYbqXDrDEL44xhsKAzdLqrP+7SQFJmu12mvpbDgYg2vZMJEVSmv4TnZ z0yoZ9n7PIKBOcMU85jRrG16/SFnr4beH5WD+buOqKiOHep670kfVByKw1zg+0IfWdzVO bUH7R+n79STQsl5NDuDxWR+dSkcG8aM9xYzntDY6Dz+6X/O5yNmBgL64pgoElfBdaNQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ynp2lYnS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58414606A68C for ; Thu, 3 Dec 2026 19:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ynp2lYnS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13BE01F000C2; Thu, 3 Dec 2026 19:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796325821; bh=SdBcA5aLZMxYz1XZLXO9CP0VkidoDsaz82ZQ4lq18Q4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Ynp2lYnSEqruWO2LW4ldsSQuvdC24+EOIXyopNJMy3DwQxb3YSHAhn28h0WvS1Npa nZ1Z8Kp26UatwfmXXm31pOpWgl74mBg5t7+Sa8woFuq+MyF1HsybZ2CyPca1xIdd3c onVEAMnL5MA3lATG/D6qqUMf5DXs/qLuauvFnF1P3AWGPCZbs5Ui9Yms3DGA9pRUPf 89D1LAsydCZzf1jcQcJ06CGj6FQ9FbK+VOd65igGXLV61ZD+mwRjMrrwolWPZKdeuX F2m2D4ww/dPUUnNBXYIRAZBPlh7Z+SGpSDgUUqhA8E2uLixUXUGmSAYqcUBTGAltIH FSBfDWiCfqvLw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ASoC: SOF: Intel: hda-codec: fix double put_device() on registration error Reply-To: sashiko-reviews@lists.linux.dev To: "Yuansheng Yang" <0xbeac@gmail.com> Cc: linux-sound@vger.kernel.org In-Reply-To: <20261203190051.456176-1-0xbeac@gmail.com> References: <20261203190051.456176-1-0xbeac@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 19:23:40 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] ASoC: SOF: Intel: Fixes tag cites 9c25af250214 instead of c344ef36dbc2 -- commit c8bb3f29aa016990712fcb39057fdf5da76515a7 Author: Yuansheng Yang <0xbeac@gmail.com> > ASoC: SOF: Intel: hda-codec: fix double put_device() on registration error > > When probing an HD-audio codec, hda_codec_probe() allocates the codec > via hda_codec_device_init() -> snd_hda_codec_device_init() -> > snd_hdac_device_init(), which initializes the embedded device reference > count (kref =3D=3D 1) and inserts the codec into bus->codec_list and > bus->caddr_tbl[] without taking an additional device reference. > > hda_codec_probe() then calls hda_codec_load_module(), which calls > snd_hdac_device_register(&codec->core). If snd_hdac_device_register() > fails (either device_add() fails or hda_widget_sysfs_init() fails and > rolls back via device_del()), hda_codec_load_module() calls > put_device(&codec->core.dev) and returns the negative error code. That > put_device() drops the sole reference and frees codec via > snd_hda_codec_dev_release(). > > Back in hda_codec_probe() -- the sole caller of hda_codec_load_module() > -- any negative return value enters the `out:` error path, which calls > snd_hdac_device_unregister(&codec->core) and put_device(&codec->core.dev) > a second time on the already-freed codec structure. > > Exercising hda_codec_probe_bus() in an x86_64 KASAN QEMU guest when > snd_hdac_device_register() fails with -EEXIST reproduces the > use-after-free and refcount underflow: > > hdaudio ehdaudio0D0: failed to register hdac device > BUG: KASAN: slab-use-after-free in snd_hdac_device_unregister+0xc6/0xe0 > Read of size 1 at addr ffff88800e15803c by task insmod/342 > Call Trace: > snd_hdac_device_unregister+0xc6/0xe0 > hda_codec_probe_bus+0x4d7/0x600 > Allocated by task 342: > snd_hda_codec_device_init+0x139/0x8e0 > hda_codec_probe_bus+0x2c9/0x600 > Freed by task 342: > kfree+0x154/0x420 > device_release+0xd2/0x270 > kobject_put+0x1b8/0x340 > put_device+0x1f/0x30 > hda_codec_probe_bus.cold+0x1c/0xbe > > followed immediately by: > > BUG: KASAN: slab-use-after-free in kobject_put+0x81/0x340 > Write of size 4 at addr ffff88800e158038 by task insmod/342 > refcount_t: underflow; use-after-free. > > Remove the redundant put_device(&codec->core.dev) call from > hda_codec_load_module() so hda_codec_probe()'s `out:` handler owns > device unregistration and the final put_device() uniformly across all > error paths, matching how snd_hda_codec_configure() handles > snd_hdac_device_register() failures. > > Fixes: 9c25af250214 ("ASoC: SOF: Intel: fix page fault at probe if i915 i= nit fails") > Cc: stable@vger.kernel.org > Signed-off-by: Yuansheng Yang <0xbeac@gmail.com> [Severity: Low] Should the Fixes tag cite commit c344ef36dbc2 ("ASoC: SOF: Intel: hda-codec: Delay the codec device registration") instead of 9c25af250214 ("ASoC: SOF: Intel: fix page fault at probe if i915 init fails")? The earlier commit added the out: cleanup path in hda_codec_probe(), but hda_codec_load_module() did not call snd_hdac_device_register() or put_device() until the later commit moved them there. With Cc: stable@vger.kernel.org present, citing the 2021 commit can direct stable backports to older branches that do not have this bug. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203190051.4561= 76-1-0xbeac@gmail.com?part=3D1