Skip to content

Commit bb37a2c

Browse files
huthstefanhaRH
authored andcommitted
tests/libqos: Check for valid dev pointer when looking for PCI devices
dev could be NULL if the PCI device can not be found due to some reasons, so we must not dereference the pointer in this case. Signed-off-by: Thomas Huth <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent a151516 commit bb37a2c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/libqos/virtio-pci.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type)
315315
qvirtio_pci_foreach(bus, device_type, false, 0,
316316
qvirtio_pci_assign_device, &dev);
317317

318-
dev->vdev.bus = &qvirtio_pci;
318+
if (dev) {
319+
dev->vdev.bus = &qvirtio_pci;
320+
}
319321

320322
return dev;
321323
}

0 commit comments

Comments
 (0)