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 -- 2.53.0
