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=1796272642; b=QsLl2MB6saMyEKEEZZ3gDpvte4aoWCYMGTfR3b48WVlFAfT85rP17K4f1LRSfDSaAX/h px+v1hX3GL11ru/qeuYE0UJOKZMch0gqci3vRbmcs9kObrUj7RinZ+2wVIImAC77GwLkj RCK/KeLQxrF5WyqiarXgiSZSmQ9ZuZpK1oH1D3e1hvKqDVLlzrcmcQUIi44Zkk+BIJuxD 304y2qCGIadO+uQ00hqAcqlab9F90EeKM6KMZhnSUy05TirDtHfOk66w5zf6UPyeOGy5m Su/JwMXs5hyMsnD3FcBgPQNdjIIA0EV0zJxmZuT4tRAfu770bXCjWia6Csn6P6XvI7w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796272642; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=b9dLsA1dkmDO4c+qbhlAZqHX9rulLac+7aA6GWUgJbI=; b=gHYXHYVadWGRIHVx7e6hj+ar/rIJmi3yXaVYtYsYq9opLH+550/TplDnxl1m/cg/AO9C m59PmDxRJDhS2B7KZ4ItWD4t+5ATVzWy73XdrHHpQw8941kiEo8ASDXqnVlyl1KfZzZsS oeLLIVtICgeEoEe/2J9KgCJcFeEKQNQIdHmB2BgUbSvofo68nm5QC6xemwJYDyL1MjXFU 04rHsAjKG17p/i5rWqHPeUBQHnoJRY0DZNMCeIN5bK58UwE0y5Q7jpgnjreUKXfVjwwiq ZT1zGY9STkvDRN1qWLb2ElL1zcNppEWSl+qRnWLmtLUVvPGQwgUl1WLU4UnbjOFIejg== 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=IRAipbDe; 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 1C174606A322 for ; Thu, 3 Dec 2026 04:37:21 +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=IRAipbDe Received: by smtp.kernel.org (Postfix) with ESMTPSA id A73B11F00893; Thu, 3 Dec 2026 04:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796272641; bh=b9dLsA1dkmDO4c+qbhlAZqHX9rulLac+7aA6GWUgJbI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=IRAipbDeCVNynh9aCsPcSCg5VjQbWG4EfHP5v8iEqAdwGh9Zvpuhuzyga5ZyqbQMt lHNMXnFbYPgmyXyQgubGj8yo//OZZDrV14Y6ZpWI9yovoi7yECkbnnPn+gR7Ows3Qf xFtacgC9JxYoJk4IcZa7ZOvuqzAEd//h+H0FN3WpnGGValtRP2h3vg6IDDM/knk3Ms 9tWSUdS20FCsh90l3EUXNslopx317ZzL7WwTYORMJuFXKTCQ2RMY2tTDuaMHT73is6 OEoUmASKmepQbZbwcl05B+ZSOk4jUupMbOYFtebgU77oiVXrrPcpEV/xm35CzOIEDX 3hBk9ZhBBHAYg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] PCI: apple: Fix device node leak in apple_msi_init() Reply-To: sashiko-reviews@lists.linux.dev To: "Yuwei Chen" <2522445001@qq.com> Cc: linux-pci@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 04:37:21 +0000 X-Mailing-List: linux-pci@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: - [Medium] PCI: apple: premature of_node_put() before irq_find_matching_fwspec() -- commit fe1b42b4279ecaebe7033a6d4f50326cbfea38ed Author: Yuwei Chen <2522445001@qq.com> PCI: apple: Fix device node leak in apple_msi_init() This commit adds of_node_put() calls in apple_msi_init() to drop the device_node reference returned by of_parse_phandle_with_args() on the error path and after populating pcie->fwspec. > diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller= /pcie-apple.c > index dfd0e345bc567..9a6d2e1e8eb42 100644 > --- a/drivers/pci/controller/pcie-apple.c > +++ b/drivers/pci/controller/pcie-apple.c > @@ -697,11 +697,14 @@ static int apple_msi_init(struct apple_pcie *pcie) > =20 > ret =3D of_property_read_u32_index(to_of_node(fwnode), "msi-ranges", > args.args_count + 1, &pcie->nvecs); > - if (ret) > + if (ret) { > + of_node_put(args.np); > return ret; > + } > =20 > of_phandle_args_to_fwspec(args.np, args.args, args.args_count, > &pcie->fwspec); > + of_node_put(args.np); > =20 > pcie->bitmap =3D devm_bitmap_zalloc(pcie->dev, pcie->nvecs, GFP_KERNEL); > if (!pcie->bitmap) [Severity: Medium] Does calling of_node_put(args.np) here leave pcie->fwspec.fwnode pointing to an unpinned device_node before irq_find_matching_fwspec() uses it? of_phandle_args_to_fwspec() only copies the fwnode pointer without taking a reference, and no parent irq_domain is guaranteed to exist yet to pin args.np. After devm_bitmap_zalloc() sleeps, irq_find_matching_fwspec() passes pcie->fwspec to registered domains' ops->select and ops->match callbacks (such as msi_lib_irq_domain_select() -> fwnode_handle_get()), which dereference fwnode->ops. If a dynamic device tree node is detached and freed in that window, irq_find_matching_fwspec() hits a use-after-free. Keeping args.np held until after irq_find_matching_fwspec() returns (and dropping it on the devm_bitmap_zalloc() error path) would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/tencent_516AA3AC285= 8D46B6E2B25A966A39463BB09@qq.com?part=3D1