All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: kvm@vger.kernel.org
Cc: "Marcelo Tosatti" <mtosatti@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Avi Kivity" <avi@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [PATCH stable-0.15 4/6] pci-assign: Harden I/O port test
Date: Tue,  9 Oct 2012 20:08:51 +0200	[thread overview]
Message-ID: <1349806133-1916-5-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1349806133-1916-1-git-send-email-afaerber@suse.de>

From: Alex Williamson <alex.williamson@redhat.com>

Markus Armbruster points out that we're missing a < 0 check
from pread while trying to probe for pci-sysfs io-port
resource support.  We don't expect a short read, but we
should harden the test to abort if we get one so we're not
potentially looking at a stale errno.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit 1d1c8a498b7ce5c5636f1014f7ad18aa4e1acc0a)

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/device-assignment.c |    5 +++--
 1 Datei geändert, 3 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index c4c2535..d586ce4 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -618,8 +618,9 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
              * kernels return EIO.  New kernels only allow 1/2/4 byte reads
              * so should return EINVAL for a 3 byte read */
             ret = pread(pci_dev->v_addrs[i].region->resource_fd, &val, 3, 0);
-            if (ret == 3) {
-                fprintf(stderr, "I/O port resource supports 3 byte read?!\n");
+            if (ret >= 0) {
+                fprintf(stderr, "Unexpected return from I/O port read: %d\n",
+                        ret);
                 abort();
             } else if (errno != EINVAL) {
                 fprintf(stderr, "Using raw in/out ioport access (sysfs - %s)\n",
-- 
1.7.10.4


  parent reply	other threads:[~2012-10-09 18:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09 18:08 [PULL stable-0.15] Stable-0.15 queue for qemu-kvm Andreas Färber
2012-10-09 18:08 ` [PATCH stable-0.15 1/6] qemu-kvm: fix improper nmi emulation Andreas Färber
2012-10-09 18:08 ` [PATCH stable-0.15 2/6] pci-assign: Fix PCI_EXP_FLAGS_TYPE shift Andreas Färber
2012-10-09 18:08 ` [PATCH stable-0.15 3/6] pci-assign: Fix PCIe lnkcap Andreas Färber
2012-10-09 18:08 ` Andreas Färber [this message]
2012-10-09 18:08 ` [PATCH stable-0.15 5/6] pci-assign: Update legacy interrupts only if used Andreas Färber
2012-10-09 18:08 ` [PATCH stable-0.15 6/6] pci-assign: Remove bogus PCIe lnkcap wmask setting Andreas Färber
2012-10-26 19:47 ` [PULL stable-0.15] Stable-0.15 queue for qemu-kvm Marcelo Tosatti

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=1349806133-1916-5-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.