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=1796432653; b=KbszcOaRpT0B+8hV/yAUtliG1BCUnN8psa48G5IAG38Zbt6F7+LdmusqrIJoilORZMoY cccBEsfW2hmJsuQse4WVoLXYv/jZVCg7fc5jAskJ2VFrUTWxYVZU+uLs4ZQOyrQDovpWu qk8lMNV6fo99slQJ0grI+yqjG/tiruqmhD7JCLPEbtdCPeLokJWFSylVuqw6uqwCC4IzX rG2NyNfWsH78Tjhjx9QNsEWV4jQ60j77xBJA+P75w1MFE2bGRJw2VtLiY1cb60kimA9vB hlJdFOw7iLRrZM91mrDU7QuwmNr1uS4w5X5qu9zdAXyD5x0580warzysP66HM0Xl9pA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796432653; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=XMr45jv1GRR/PYErxf7eUr1mt08ySH9m9440WfnQg2g=; b=m2/prOqjPDF2l4VEwOrEEAVvFc7FEwt2e0tfaSC2DCFgTLQ1OGQb9q2ObcxOiw6eV95Y egA7rIrbhw2Wc7naz4OxAFQtFBD2XRn0cxqvx2jDHUVdE83JodTVzww5cczjx0JBdun8h qQZ9/iGdy/jgdhLzNJHKP1GjAE/rlXZm//AZr1VyEJmpVeSO6jKQASip4VatijiR1qAu7 tdmvdWjiHA2VAFgdKhyi/GD2BrqLCfavniK2zqRJkTLNEQnF+7t/OG7YyYlTNW59IVOL+ D7lcCy/jyQ0IyuJiLOpEXGGI6wASy4zZuMpO6eTH7xVEtCK2l9CgakJm70Mb2lFJuEw== 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=Zu7SAar9; 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 D5C56606A322 for ; Sat, 5 Dec 2026 01:04:13 +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=Zu7SAar9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77F2B1F0092B; Sat, 5 Dec 2026 01:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796432653; bh=XMr45jv1GRR/PYErxf7eUr1mt08ySH9m9440WfnQg2g=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Zu7SAar9HItOMmpb1tYdClBFP/8i2L9UKXEpmhWLSALzQ7vfPqH3NKWJNIxiFto8d sZs7DEWS8RX+j0C9v/pdV4NuAfNqTqEmOAZtnVCpXsF4EEKDz5YWpPJij7Yfr7NI5a b4Hw9S7bkclVo/b7j43OeqN7hxI9mt7+MsZcnq9RNqe8lyKQ0DM2wd11bHKgxtGMLY MZ7HpxxrgTfr6s22I08f9nihW0JIKnl0g5Io3oMl6T17I+/6JpFEL+XV0zvI9o6Iki cygzhtGRMkQPXrLBexVEEd3ulcnXjkfykfy0eUIZRBNXRjSKscF8tN7itAxQG8wQoV jGk2sUXs5ZP/g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 03/16] PCI: Abort BAR resize only if saving the resized BAR fails Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?SWxwbyBKw6RydmluZW4=?= , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-pci@vger.kernel.org In-Reply-To: <20261205003957.3304-4-ilpo.jarvinen@linux.intel.com> References: <20261205003957.3304-1-ilpo.jarvinen@linux.intel.com> <20261205003957.3304-4-ilpo.jarvinen@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 01:04:13 +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 2 potential issues to consider: - [Medium] PCI: continuing after -ENOMEM in pci_do_resource_release_and_resize() - [Medium] PCI: pci_do_resource_release_and_resize() skips unsaved unassigned BARs -- commit 2e0d31c7b9377b1d5689204c149a99e359a637cb Author: Ilpo J=C3=A4rvinen PCI: Abort BAR resize only if saving the resized BAR fails This commit changes pci_do_resource_release_and_resize() so that a failure to save a BAR in the saved list only aborts and rolls back when the failing BAR is the one being resized, leaving other BARs in place and continuing. > diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c > index db16c8c2913d6..c18664b5e5a25 100644 > --- a/drivers/pci/setup-bus.c > +++ b/drivers/pci/setup-bus.c > @@ -2407,8 +2407,11 @@ int pci_do_resource_release_and_resize(struct pci_= dev *pdev, int resno, int size > continue; > =20 > ret =3D pci_dev_res_add_to_list(&saved, pdev, r, 0, 0); > - if (ret) > - goto restore; > + if (ret) { > + if (i =3D=3D resno) > + goto restore; > + continue; > + } > pci_release_resource(pdev, i); > } [Severity: Medium] Can continuing after pci_dev_res_add_to_list() fails with -ENOMEM turn a clean rollback into a kernel panic? pci_dev_res_add_to_list() only fails when kzalloc_obj() cannot allocate a struct pci_dev_resource. If that happens for a sibling BAR after the resized BAR was already released, leaving the sibling BAR assigned keeps b_win->child non-NULL. pbus_reassign_bridge_resources() then skips its own save check and calls into pdev_sort_resources(), which allocates the same struct pci_dev_resource with kzalloc_obj() for the released resized BAR and panics on failure. Even if the allocation failure is transient, leaving the sibling BAR assigned pins the bridge window and can mask the -ENOMEM as -ENOSPC. [Severity: Medium] What happens if the unsaved sibling BAR is currently unassigned rather than assigned? Because this loop does not check resource_assigned(r), an unassigned BAR with non-zero flags (for example, on a PCI_PROBE_ONLY platform) still matches b_win via pbus_select_window(). Continuing on error leaves it unassigned and absent from saved. When b_win is not released (for example, when exclude_bars keeps another BAR in place), pdev_sort_resources() includes that unassigned BAR and can assign it into resno's vacated range while the enlarged resno fails with -ENOSPC. Rollback only releases resources tracked in saved and their children, so neither b_win nor the sibling BAR is released. pci_claim_resource() for resno then fails with -EBUSY, leaving the resized BAR unassigned. Checking (i =3D=3D resno || !resource_assigned(r)) before jumping to restore would avoid leaving an unassigned BAR untracked. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205003957.3304= -1-ilpo.jarvinen@linux.intel.com?part=3D3