aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2018-02-27 07:44:44 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2018-03-05 09:03:17 +0000
commitbb37a2c0b51f74e7bd9a1f87ca4ec1648e1f9398 (patch)
treee7751bf43dbb80d080b8dd8a8af2905e8319f005 /tests/libqos
parenta1515161b563acd0986867fc37084c1cf952ba35 (diff)
downloadqemu-bb37a2c0b51f74e7bd9a1f87ca4ec1648e1f9398.zip
qemu-bb37a2c0b51f74e7bd9a1f87ca4ec1648e1f9398.tar.gz
qemu-bb37a2c0b51f74e7bd9a1f87ca4ec1648e1f9398.tar.bz2
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>
Diffstat (limited to 'tests/libqos')
-rw-r--r--tests/libqos/virtio-pci.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index 7ac15c0..550dede 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -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_assign_device, &dev);
- dev->vdev.bus = &qvirtio_pci;
+ if (dev) {
+ dev->vdev.bus = &qvirtio_pci;
+ }
return dev;
}