xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: peter.maydell@linaro.org, stefanha@gmail.com
Cc: anthony.perard@citrix.com, xen-devel@lists.xenproject.org,
	sstabellini@kernel.org, qemu-devel@nongnu.org,
	stefanha@redhat.com
Subject: [PULL for-2.10 2/7] xen_pt_msi.c: Check for xen_host_pci_get_* failures in xen_pt_msix_init()
Date: Tue, 18 Jul 2017 15:22:37 -0700	[thread overview]
Message-ID: <1500416562-27337-2-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <1500416562-27337-1-git-send-email-sstabellini@kernel.org>

From: Peter Maydell <peter.maydell@linaro.org>

Check the return status of the xen_host_pci_get_* functions we call in
xen_pt_msix_init(), and fail device init if the reads failed rather than
ploughing ahead. (Spotted by Coverity: CID 777338.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
---
 hw/xen/xen_pt_msi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c
index 62add06..ff9a79f 100644
--- a/hw/xen/xen_pt_msi.c
+++ b/hw/xen/xen_pt_msi.c
@@ -535,7 +535,11 @@ int xen_pt_msix_init(XenPCIPassthroughState *s, uint32_t base)
         return -1;
     }
 
-    xen_host_pci_get_word(hd, base + PCI_MSIX_FLAGS, &control);
+    rc = xen_host_pci_get_word(hd, base + PCI_MSIX_FLAGS, &control);
+    if (rc) {
+        XEN_PT_ERR(d, "Failed to read PCI_MSIX_FLAGS field\n");
+        return rc;
+    }
     total_entries = control & PCI_MSIX_FLAGS_QSIZE;
     total_entries += 1;
 
@@ -554,7 +558,11 @@ int xen_pt_msix_init(XenPCIPassthroughState *s, uint32_t base)
                            + XC_PAGE_SIZE - 1)
                           & XC_PAGE_MASK);
 
-    xen_host_pci_get_long(hd, base + PCI_MSIX_TABLE, &table_off);
+    rc = xen_host_pci_get_long(hd, base + PCI_MSIX_TABLE, &table_off);
+    if (rc) {
+        XEN_PT_ERR(d, "Failed to read PCI_MSIX_TABLE field\n");
+        goto error_out;
+    }
     bar_index = msix->bar_index = table_off & PCI_MSIX_FLAGS_BIRMASK;
     table_off = table_off & ~PCI_MSIX_FLAGS_BIRMASK;
     msix->table_base = s->real_device.io_regions[bar_index].base_addr;
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-07-18 22:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 22:20 [PULL for-2.0 0/7] please pull xen-20170718-tag Stefano Stabellini
2017-07-18 22:22 ` [PULL for-2.10 1/7] hw/xen: Set emu_mask for igd_opregion register Stefano Stabellini
2017-07-18 22:22   ` Stefano Stabellini [this message]
2017-07-18 22:22   ` [PULL for-2.10 3/7] xen-platform: separate unplugging of NVMe disks Stefano Stabellini
2017-07-18 22:22   ` [PULL for-2.10 4/7] xen: move physmap saving into a separate function Stefano Stabellini
2017-07-18 22:22   ` [PULL for-2.10 5/7] xen/mapcache: add an ability to create dummy mappings Stefano Stabellini
2017-07-18 22:22   ` [PULL for-2.10 6/7] xen/mapcache: introduce xen_replace_cache_entry() Stefano Stabellini
2017-07-21 13:50     ` Anthony PERARD
2017-07-21 18:35       ` Igor Druzhinin
2017-07-22  0:28         ` Stefano Stabellini
2017-07-18 22:22   ` [PULL for-2.10 7/7] xen: don't use xenstore to save/restore physmap anymore Stefano Stabellini
2017-07-19 16:50 ` [PULL for-2.0 0/7] please pull xen-20170718-tag 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=1500416562-27337-2-git-send-email-sstabellini@kernel.org \
    --to=sstabellini@kernel.org \
    --cc=anthony.perard@citrix.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.com \
    --cc=xen-devel@lists.xenproject.org \
    /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).