>-----Original Message-----
>From: Eric Auger <eric.au...@redhat.com>
>Sent: Thursday, October 12, 2023 4:10 AM
>To: eric.auger....@gmail.com; eric.au...@redhat.com; qemu-
>de...@nongnu.org; alex.william...@redhat.com; c...@redhat.com; Duan,
>Zhenzhong <zhenzhong.d...@intel.com>; Liu, Yi L <yi.l....@intel.com>;
>yangh...@redhat.com
>Subject: [PATCH] vfio/pci: Remove vfio_detach_device from vfio_realize error
>path
>
>In vfio_realize, on the error path, we currently call
>vfio_detach_device() after a successful vfio_attach_device.
>While this looks natural, vfio_instance_finalize also induces
>a vfio_detach_device(), and it seems to be the right place
>instead as other resources are released there which happen
>to be a prerequisite to a successful UNSET_CONTAINER.
>
>So let's rely on the finalize vfio_detach_device call to free
>all the relevant resources.
>
>Fixes: a28e06621170 ("vfio/pci: Introduce vfio_[attach/detach]_device")
>Reported-by: Zhenzhong Duan <zhenzhong.d...@intel.com>
>Signed-off-by: Eric Auger <eric.au...@redhat.com>
Tested-by: Zhenzhong Duan <zhenzhong.d...@intel.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.d...@intel.com>
Thanks
Zhenzhong