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 <thuth@redhat.com>
Message-id: 1519713884-2346-1-git-send-email-thuth@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Thomas Huth 2018-02-27 07:44:44 +01:00 committed by Stefan Hajnoczi
parent a1515161b5
commit bb37a2c0b5

View File

@ -315,7 +315,9 @@ QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type)
qvirtio_pci_foreach(bus, device_type, false, 0, qvirtio_pci_foreach(bus, device_type, false, 0,
qvirtio_pci_assign_device, &dev); qvirtio_pci_assign_device, &dev);
dev->vdev.bus = &qvirtio_pci; if (dev) {
dev->vdev.bus = &qvirtio_pci;
}
return dev; return dev;
} }