qemu/hw/vfio
Avihai Horon 5c4dbcb748 vfio/migration: Fix NULL pointer dereference bug
As part of its error flow, vfio_vmstate_change() accesses
MigrationState->to_dst_file without any checks. This can cause a NULL
pointer dereference if the error flow is taken and
MigrationState->to_dst_file is not set.

For example, this can happen if VM is started or stopped not during
migration and vfio_vmstate_change() error flow is taken, as
MigrationState->to_dst_file is not set at that time.

Fix it by checking that MigrationState->to_dst_file is set before using
it.

Fixes: 02a7e71b1e ("vfio: Add VM state change handler to know state of VM")
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Link: https://lore.kernel.org/r/20230216143630.25610-3-avihaih@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2023-02-16 12:13:46 -07:00
..
amd-xgbe.c Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
ap.c target/s390x: move kvm files into kvm/ 2021-07-07 14:01:59 +02:00
calxeda-xgmac.c Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
ccw.c vfio-ccw: forward halt/clear errors 2021-09-06 16:22:54 +02:00
common.c vfio: move implement of vfio_get_xlat_addr() to memory.c 2022-11-07 14:08:17 -05:00
display.c ui/console: Do not return a value with ui_info 2022-06-14 10:34:37 +02:00
igd.c Mark remaining global TypeInfo instances as const 2022-02-21 13:30:20 +00:00
Kconfig hw/vfio: Move the IGD quirk code to a separate file 2020-02-06 11:55:42 -07:00
meson.build vfio: Add migration region initialization and finalize function 2020-11-01 12:30:50 -07:00
migration.c vfio/migration: Fix NULL pointer dereference bug 2023-02-16 12:13:46 -07:00
pci-quirks.c hw/vfio/pci-quirks: Resolve redundant property getters 2022-05-24 10:38:50 +10:00
pci.c vfio/pci: Use vbasedev local variable in vfio_realize() 2022-05-06 09:06:50 -06:00
pci.h include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
platform.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
spapr.c Replace qemu_real_host_page variables with inlined functions 2022-04-06 10:50:38 +02:00
trace-events migration: Remove unused res_compatible 2023-02-15 20:04:30 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00