Skip to content

Commit

Permalink
tests/libqos: Check for valid dev pointer when looking for PCI devices
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
huth authored and stefanhaRH committed Mar 5, 2018
1 parent a151516 commit bb37a2c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/libqos/virtio-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit bb37a2c

Please sign in to comment.