[Qemu-devel] [PATCH] tests/libqos: Check for valid dev pointer when looking for PCI devices

Thomas Huth posted 1 patch 7 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1519713884-2346-1-git-send-email-thuth@redhat.com
Test checkpatch passed
Test docker-build@min-glib passed
Test docker-mingw@fedora passed
Test docker-quick@centos6 passed
Test ppcbe passed
Test ppcle passed
Test s390x passed
tests/libqos/virtio-pci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH] tests/libqos: Check for valid dev pointer when looking for PCI devices
Posted by Thomas Huth 7 years, 7 months ago
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>
---
 tests/libqos/virtio-pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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;
 }
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH] tests/libqos: Check for valid dev pointer when looking for PCI devices
Posted by Stefan Hajnoczi 7 years, 7 months ago
On Tue, Feb 27, 2018 at 07:44:44AM +0100, Thomas Huth wrote:
> 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>
> ---
>  tests/libqos/virtio-pci.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

There is no maintainer for tests/libqos/virtio-pci.c in MAINTAINERS so
I'll take this patch.

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan