Sfoglia il codice sorgente

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>
Thomas Huth 7 anni fa
parent
commit
bb37a2c0b5
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      tests/libqos/virtio-pci.c

+ 3 - 1
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;
 }