From: Alex Williamson <alex@shazbot.org>
To: <mhonap@nvidia.com>
Cc: <jgg@ziepe.ca>, <yishaih@nvidia.com>, <sumit.semwal@linaro.org>,
<kvm@vger.kernel.org>, <virtualization@lists.linux.dev>,
<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<linaro-mm-sig@lists.linaro.org>, <linux-cxl@vger.kernel.org>,
alex@shazbot.org
Subject: Re: [PATCH 2/5] vfio/virtio: Release vfio-pci-core state when legacy I/O setup fails
Date: Wed, 2 Dec 2026 16:19:23 -0700 [thread overview]
Message-ID: <20261202161923.71db314d@shazbot.org> (raw)
In-Reply-To: <20261202093250.1683744-3-mhonap@nvidia.com>
On Wed, 2 Dec 2026 15:02:47 +0530
<mhonap@nvidia.com> wrote:
> 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
>
This should be framed as a fix, even without the coming list
allocation, the mutex init vs destroy is unbalanced. The QAT driver is
the only other variant driver with failures after
vfio_pci_core_init_dev() and it correctly calls release. The bug seems
to date back to eb61eca0e8c3.
Also note that in patch 3, you're introducing a call that can fail at
the end of vfio_pci_core_init_dev() that also doesn't unwind. That
needs to be fixed inside vfio_pci_core_init_dev(). Thanks,
Alex
next prev parent reply other threads:[~2026-12-02 23:19 UTC|newest]
Thread overview: 12+ 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 23:19 ` Alex Williamson
2026-12-02 9:32 ` [PATCH 2/5] vfio/virtio: Release vfio-pci-core state when legacy I/O setup fails mhonap
2026-12-02 23:19 ` Alex Williamson [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 23:19 ` Alex Williamson
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
2026-12-02 23:19 ` Alex Williamson
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=20261202161923.71db314d@shazbot.org \
--to=alex@shazbot.org \
--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=mhonap@nvidia.com \
--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