qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 4/6] tests/libqos: Check for valid dev pointer when looking for PCI devices
Date: Mon,  5 Mar 2018 09:40:04 +0000	[thread overview]
Message-ID: <20180305094006.21446-5-stefanha@redhat.com> (raw)
In-Reply-To: <20180305094006.21446-1-stefanha@redhat.com>

From: Thomas Huth <thuth@redhat.com>

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>
---
 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 7ac15c04e1..550dede0a2 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;
 }
-- 
2.14.3

  parent reply	other threads:[~2018-03-05  9:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05  9:40 [Qemu-devel] [PULL 0/6] Block patches Stefan Hajnoczi
2018-03-05  9:40 ` [Qemu-devel] [PULL 1/6] util/uri.c: Coding style check, Only whitespace involved Stefan Hajnoczi
2018-03-05  9:40 ` [Qemu-devel] [PULL 2/6] util/uri.c: remove brackets that wrap `return` statement's content Stefan Hajnoczi
2018-03-05  9:40 ` [Qemu-devel] [PULL 3/6] util/uri.c: wrap single statement blocks with braces {} Stefan Hajnoczi
2018-03-05  9:40 ` Stefan Hajnoczi [this message]
2018-03-05  9:40 ` [Qemu-devel] [PULL 5/6] Add a git-publish configuration file Stefan Hajnoczi
2018-03-05  9:40 ` [Qemu-devel] [PULL 6/6] README: Document 'git-publish' workflow Stefan Hajnoczi
2018-03-05 10:51   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-03-05 12:23     ` Fam Zheng
2018-03-05  9:52 ` [Qemu-devel] [PULL 0/6] Block patches no-reply
2018-03-05 18:55 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180305094006.21446-5-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).