qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/pci: vfio_pci_put_device on failure
@ 2025-05-27 20:56 Steve Sistare
  2025-05-27 23:29 ` John Levon
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Sistare @ 2025-05-27 20:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cedric Le Goater, Alex Williamson, Steve Sistare

If vfio_realize fails after vfio_device_attach, it should call
vfio_device_detach during error recovery.  If it fails after
vfio_device_get_name, it should free vbasedev->name.  If it fails
after vfio_pci_config_setup, it should free vdev->msix.

To fix all, call vfio_pci_put_device().

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 hw/vfio/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index a1bfdfe..7d3b9ff 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3296,6 +3296,7 @@ out_teardown:
     vfio_bars_exit(vdev);
 error:
     error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name);
+    vfio_pci_put_device(vdev);
 }
 
 static void vfio_instance_finalize(Object *obj)
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] vfio/pci: vfio_pci_put_device on failure
  2025-05-27 20:56 [PATCH] vfio/pci: vfio_pci_put_device on failure Steve Sistare
@ 2025-05-27 23:29 ` John Levon
  0 siblings, 0 replies; 2+ messages in thread
From: John Levon @ 2025-05-27 23:29 UTC (permalink / raw)
  To: Steve Sistare; +Cc: qemu-devel, Cedric Le Goater, Alex Williamson

On Tue, May 27, 2025 at 01:56:52PM -0700, Steve Sistare wrote:

> If vfio_realize fails after vfio_device_attach, it should call
> vfio_device_detach during error recovery.  If it fails after
> vfio_device_get_name, it should free vbasedev->name.  If it fails
> after vfio_pci_config_setup, it should free vdev->msix.
> 
> To fix all, call vfio_pci_put_device().
> 
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
>  hw/vfio/pci.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index a1bfdfe..7d3b9ff 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -3296,6 +3296,7 @@ out_teardown:
>      vfio_bars_exit(vdev);
>  error:
>      error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name);
> +    vfio_pci_put_device(vdev);
>  }
>  
>  static void vfio_instance_finalize(Object *obj)

Reviewed-by: John Levon <john.levon@nutanix.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-27 23:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 20:56 [PATCH] vfio/pci: vfio_pci_put_device on failure Steve Sistare
2025-05-27 23:29 ` John Levon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).