]> git.ipfire.org Git - thirdparty/qemu.git/commit
vfio/pci: Fix a segfault in vfio_realize
authorZhenzhong Duan <zhenzhong.duan@intel.com>
Thu, 29 Jun 2023 08:40:38 +0000 (16:40 +0800)
committerMichael Tokarev <mjt@tls.msk.ru>
Fri, 30 Jun 2023 16:00:39 +0000 (19:00 +0300)
commitc7b6b705efe583964ceacb1fba66a0d06cba8325
tree639d32c1a182620059d88f086ec5abb363799944
parent4d8459c36596c881db28319044aef8145ef91819
vfio/pci: Fix a segfault in vfio_realize

The kvm irqchip notifier is only registered if the device supports
INTx, however it's unconditionally removed in vfio realize error
path. If the assigned device does not support INTx, this will cause
QEMU to crash when vfio realize fails. Change it to conditionally
remove the notifier only if the notify hook is setup.

Before fix:
(qemu) device_add vfio-pci,host=81:11.1,id=vfio1,bus=root1,xres=1
Connection closed by foreign host.

After fix:
(qemu) device_add vfio-pci,host=81:11.1,id=vfio1,bus=root1,xres=1
Error: vfio 0000:81:11.1: xres and yres properties require display=on
(qemu)

Fixes: c5478fea27ac ("vfio/pci: Respond to KVM irqchip change notifier")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
(cherry picked from commit 357bd7932a136613d700ee8bc83e9165f059d1f7)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/vfio/pci.c