mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@nvidia.com>
To: kvm <kvm@vger.kernel.org>, Alex Williamson <alex@shazbot.org>
Cc: Alex Williamson <alex.williamson@nvidia.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>,
	kanie@linux.alibaba.com, stable@vger.kernel.org
Subject: [PATCH v3 2/6] vfio/pci: Release the VGA arbiter client on register_device() failure
Date: Mon, 15 Jun 2026 13:12:30 -0600	[thread overview]
Message-ID: <20260615191241.688297-3-alex.williamson@nvidia.com> (raw)
In-Reply-To: <20260615191241.688297-1-alex.williamson@nvidia.com>

The re-order in the Fixes commit below displaced vfio_pci_vga_init() as
the last failure point of what is now vfio_pci_core_register_device()
without introducing an unwind for the VGA arbiter registration.

In current kernels this is mostly benign because vfio_pci_set_decode()
only uses pci_dev state, but the original failure path could leave a
callback with a freed vdev cookie.  The stale registration also becomes
unsafe again once the callback follows drvdata to the vfio device.

Add the required VGA unwind callout.

Fixes: 4aeec3984ddc ("vfio/pci: Re-order vfio_pci_probe()")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Alex Williamson <alex.williamson@nvidia.com>
---
 drivers/vfio/pci/vfio_pci_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index f8d1755de2ce..dab82c078580 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -2254,6 +2254,7 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev)
 		pm_runtime_get_noresume(dev);
 
 	pm_runtime_forbid(dev);
+	vfio_pci_vga_uninit(vdev);
 out_vf:
 	vfio_pci_vf_uninit(vdev);
 	return ret;
-- 
2.53.0


  parent reply	other threads:[~2026-06-15 19:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 19:12 [PATCH v3 0/6] vfio/pci: Latch module params, fix bitfield use and VGA unwind Alex Williamson
2026-06-15 19:12 ` [PATCH v3 1/6] vfio/pci: Latch disable_idle_d3 per device Alex Williamson
2026-06-15 19:12 ` Alex Williamson [this message]
2026-06-15 19:12 ` [PATCH v3 3/6] vfio/pci: Fix racy bitfields and tighten struct layout Alex Williamson
2026-06-15 19:12 ` [PATCH v3 4/6] vfio/mlx5: " Alex Williamson
2026-06-15 19:12 ` [PATCH v3 5/6] vfio/pci: Latch all module parameters per device Alex Williamson
2026-06-15 19:12 ` [PATCH v3 6/6] vfio/pci: Expose latched module parameter policy in debugfs Alex Williamson
2026-06-15 20:47 ` [PATCH v3 7/6] vfio: Remove device debugfs before releasing devres Alex Williamson
2026-06-17  7:46 ` [PATCH v3 0/6] vfio/pci: Latch module params, fix bitfield use and VGA unwind Tian, Kevin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260615191241.688297-3-alex.williamson@nvidia.com \
    --to=alex.williamson@nvidia.com \
    --cc=alex@shazbot.org \
    --cc=jgg@ziepe.ca \
    --cc=kanie@linux.alibaba.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®