vfio/container: Fix SIGSEGV when open container file fails

When open /dev/vfio/vfio fails, SIGSEGV triggers because
vfio_listener_unregister() doesn't support a NULL bcontainer
pointer.

Fixes: a1f267a7d4 ("vfio/container: reform vfio_container_connect cleanup")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250623102235.94877-2-zhenzhong.duan@intel.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
Zhenzhong Duan
2025-06-26 08:55:37 +02:00
committed by Cédric Le Goater
parent eafb408629
commit abc6249d42
+3 -1
View File
@@ -710,7 +710,9 @@ static bool vfio_container_connect(VFIOGroup *group, AddressSpace *as,
return true;
fail:
vfio_listener_unregister(bcontainer);
if (new_container) {
vfio_listener_unregister(bcontainer);
}
if (group_was_added) {
vfio_container_group_del(container, group);