From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BBBD606A322 for ; Sat, 5 Dec 2026 01:04:31 +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: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4649C11321D; Sat, 5 Dec 2026 01:04:26 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D82B10E8C4; Sat, 5 Dec 2026 01:04:14 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id CE44345DC5; Sat, 5 Dec 2026 01:04:13 +0000 (UTC) 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 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-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Intel-xe" X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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