From: <mhonap@nvidia.com>
To: <jgg@ziepe.ca>, <yishaih@nvidia.com>, <sumit.semwal@linaro.org>
Cc: <kvm@vger.kernel.org>, <virtualization@lists.linux.dev>,
<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<linaro-mm-sig@lists.linaro.org>, <mhonap@nvidia.com>,
<linux-cxl@vger.kernel.org>
Subject: [PATCH 2/5] vfio/virtio: Release vfio-pci-core state when legacy I/O setup fails
Date: Wed, 2 Dec 2026 15:02:47 +0530 [thread overview]
Message-ID: <20261202093250.1683744-3-mhonap@nvidia.com> (raw)
In-Reply-To: <20261202093250.1683744-1-mhonap@nvidia.com>
From: Manish Honap <mhonap@nvidia.com>
virtiovf_pci_init_device() returns the error of virtiovf_init_legacy_io()
without undoing vfio_pci_core_init_dev(). vfio_init_device() does not
call .release when .init fails, so the state vfio_pci_core_init_dev()
set up is not released.
Today that state needs no freeing. vfio_pci_core_init_dev() is about to
allocate an excluded-range entry for the MSI-X table, which would leak on
this path. Call vfio_pci_core_release_dev() when
virtiovf_init_legacy_io() fails.
Signed-off-by: Manish Honap <mhonap@nvidia.com>
---
drivers/vfio/pci/virtio/main.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/pci/virtio/main.c b/drivers/vfio/pci/virtio/main.c
index 123ff5193812..f1ca774889f8 100644
--- a/drivers/vfio/pci/virtio/main.c
+++ b/drivers/vfio/pci/virtio/main.c
@@ -69,7 +69,10 @@ static int virtiovf_pci_init_device(struct vfio_device *core_vdev)
* The vfio_device_ops.init() callback is set to virtiovf_pci_init_device()
* only when legacy I/O is supported. Now, let's initialize it.
*/
- return virtiovf_init_legacy_io(virtvdev);
+ ret = virtiovf_init_legacy_io(virtvdev);
+ if (ret)
+ vfio_pci_core_release_dev(core_vdev);
+ return ret;
}
#endif
--
2.53.0
next prev parent reply other threads:[~2026-12-02 9:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 9:32 [PATCH 0/5] vfio/pci: Per-BAR excluded ranges mhonap
2026-12-02 9:32 ` [PATCH 1/5] vfio/pci: Move the excluded windows out of vfio_pci_core_do_io_rw() mhonap
2026-12-02 9:44 ` sashiko-bot
2026-12-02 9:32 ` mhonap [this message]
2026-12-02 9:32 ` [PATCH 3/5] vfio/pci: Add per-BAR excluded ranges and put the MSI-X table on them mhonap
2026-12-02 9:32 ` [PATCH 4/5] vfio/pci: Advertise the mmap areas around excluded ranges mhonap
2026-12-02 9:32 ` [PATCH 5/5] vfio/pci: Refuse ioeventfds and dma-buf exports over " mhonap
2026-12-02 9:42 ` sashiko-bot
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=20261202093250.1683744-3-mhonap@nvidia.com \
--to=mhonap@nvidia.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=kvm@vger.kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=virtualization@lists.linux.dev \
--cc=yishaih@nvidia.com \
/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