> -----Original Message-----
> From: Alex Williamson <[email protected]>
> Sent: Thursday, December 3, 2026 4:49 AM
> To: Manish Honap <[email protected]>
> Cc: [email protected]; Yishai Hadas <[email protected]>;
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; linaro-mm-
> [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH 2/5] vfio/virtio: Release vfio-pci-core state when legacy
> I/O
> setup fails
>
> External email: Use caution opening links or attachments
>
>
> On Wed, 2 Dec 2026 15:02:47 +0530
> <[email protected]> wrote:
>
> > From: Manish Honap <[email protected]>
> >
> > 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 <[email protected]>
> > ---
> > 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,
Okay, I will update the series to mention this patch with a Fixes:
I will also update the vfio_pci_core_init_dev to destroy the mutices when MSI-X
range add fails.
Thanks,
Manish
>
> Alex