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=1796460622; b=Oa+RhQ4HL26JcLiltcHOoOMGu8ixyjEo8NB8gehhWxHx97ol0mYX1ohQZujrM2UeWObr xuisCm2OPMSUkNV0Ixr/Vv4Id5GvEpOA2UtrgqL06hF3s+rL7GI29CzcRcXPXVKGI038b hLVcEPgZ0FoqheiCFOh1S+USvxRhTZ+5Dfu9Vhz4RhfHm4n4ncwsDn4G0RlCTMFK+84Q/ OZ73IQM1wS22TWrFvQedv2XraCplroB13QB9HDZ3zkhR0kKe2f3VVBLRyF7WqxO4OSE3P 7nZrfRqvD/frjpqBn1NE484xnGaMOTbpTklOQ7PIAsEGMWjpVF5DbWZ6XEdp5dVwA0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796460622; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=DAs07EvaX6sO2Gos3porbXgJ5jisVp/g+YT5i/NMOY0=; b=jT78sxL1vhO+13NEiXxXTcgEVsiBsNtoTB51FU6TD1zubsypotcgq/+QJiLygDAyADND B07yVkgXit1W6DWlAjn/dotbShuT70VPrv+jJd0G7U99qKNwAZu1ztmZve44F8JlGUzPn yml1qmfh3Z1FZN0JQqPGymIaafty2OIEc+p/JqOOcuETB77GIVWNmPHT6Dnj+fjFBfp4L 0rw+UZy8SxhkjF9J1Sb8hHA1lYDwXmDLAyh7VGZqwE1F18zr1lh2Q6roAE2OAdiUOwMdw tZHeB4wnHiAf9C4Z2PFggapMf4+1tW2SKNP3WwEYW/o+Pz789576fIa96j23dvr6dEA== 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=de8wccuu; 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 818E6606A322 for ; Sat, 5 Dec 2026 08:50:22 +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=de8wccuu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 077B61F00936; Sat, 5 Dec 2026 08:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796460622; bh=DAs07EvaX6sO2Gos3porbXgJ5jisVp/g+YT5i/NMOY0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=de8wccuuHs3A9VQEC3eFs8V4JxY20NdAAUXnyyH6lax8ER62IzWDZKo++4PkA0Wik QB/kIiqDVDRSf960/moAzsto7lKkmV1CUzhmkXrNBR7NBbtkR4xBE4uQ9ZBslUKind T7CQw1NRTPCDKVmdFTOuiMZ8xnZaHh46dUPE/+gElIkV+wHHfx5AGkSsNDxjjX+QJy fGnTzFDOVRU1eK9a404MlspxL9wLb6xT0h4/ZXQ/l0I2mCdRyIoKhLEij/wLhTOgQR 8vRyEdtQsA4hg0U1C/FCAPZjPbzFRkA86NeowZRzIylwfZnxZbi9LPQvsMLHeHOUBw pXYDjVxBWIfZg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 01/14] thunderbolt: Fix error handling and unwind paths in nhi_probe() Reply-To: sashiko-reviews@lists.linux.dev To: "Chunfeng Yun" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261205083342.4009278-2-chunfeng.yun@mediatek.com> References: <20261205083342.4009278-1-chunfeng.yun@mediatek.com> <20261205083342.4009278-2-chunfeng.yun@mediatek.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 08:50:20 +0000 X-Mailing-List: linux-usb@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] thunderbolt: Fixes tag in nhi_probe() cites refactor commit e241d98e04ef -- commit eee24f59504b2e86fb4bdbccff24c965b0e09126 Author: Chunfeng Yun > thunderbolt: Fix error handling and unwind paths in nhi_probe() > > Currently, nhi_probe() has several issues in its error unwind > paths: > > 1. Incomplete cleanup on failure: > If an error occurs after interrupts are initialized, such as in > nhi->ops->init() or nhi_select_cm(), nhi_probe() immediately > returns without calling nhi_shutdown(). > This leaves resources uncleaned: > - Hardware interrupt registers remain unmasked. > - Any scheduled nhi->interrupt_work is not flushed before the driver > core frees the tb_nhi structure, risking a use-after-free. > - For Ice Lake PCIe controllers, icl_nhi_ops.init powers on the > controller, but icl_nhi_shutdown() is never called to turn > force-power back off, leaking power. > > 2. Fragile initialization order: > dma_set_mask_and_coherent() and spin_lock_init(&nhi->lock) are called > after nhi->ops->init_interrupts(). If a hardware interrupt fires > immediately upon registration, nhi_msi() schedules interrupt_work, > which acquires &nhi->lock before it is initialized. Furthermore, if > DMA mask configuration fails, interrupts have already been allocated > and must be torn down. > > Improve the probe sequence and error handling: > - Move dma_set_mask_and_coherent() and spin_lock_init() before > nhi->ops->init_interrupts(). If DMA mask setup fails, exit early > before interrupts are enabled. > - Handle post-interrupt error paths by nhi_shutdown(). > > Fixes: e241d98e04ef ("thunderbolt: Separate out common NHI bits") > > Signed-off-by: Chunfeng Yun [Severity: Low] Does the Fixes tag point to the right commit? Commit e241d98e04ef ("thunderbolt: Separate out common NHI bits") only refactored PCI helpers out of nhi.c and preserved the existing probe order and error paths, so citing it keeps stable-tree automation from finding older kernels. These bugs were introduced by earlier commits: - 16603153666d ("thunderbolt: Add initial cactus ridge NHI support") for initializing nhi->lock after IRQ registration (converted to a spinlock in 59120e06101d ("thunderbolt: Use spinlock in NHI serialization")) - 9d3cce0b6136 ("thunderbolt: Introduce thunderbolt bus and connection manager") for returning without nhi_shutdown() when connection manager selection fails - dba3caf62103 ("thunderbolt: Use 64-bit DMA mask if supported by the platform") for calling dma_set_mask_and_coherent() after interrupt setup without nhi_shutdown() on failure - 3cdb9446a117 ("thunderbolt: Add support for Intel Ice Lake") for returning without nhi_shutdown() when nhi->ops->init() fails Should the Fixes tag reference the introducing commit(s) instead? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205083342.4009= 278-1-chunfeng.yun@mediatek.com?part=3D1