From: Zhenzhong Duan Date: Mon, 23 Jun 2025 10:22:32 +0000 (+0800) Subject: vfio/container: Fix SIGSEGV when open container file fails X-Git-Tag: v10.1.0-rc0~40^2~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=abc6249d42f9681d5b659716434ef374c6e0edef;p=thirdparty%2Fqemu.git 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: a1f267a7d4d9 ("vfio/container: reform vfio_container_connect cleanup") Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater Link: https://lore.kernel.org/qemu-devel/20250623102235.94877-2-zhenzhong.duan@intel.com Signed-off-by: Cédric Le Goater --- diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 3e8d645ebbd..2853f6f08b5 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -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);