qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: alex.williamson@redhat.com
Cc: lersek@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH for-2.4 2/2] vfio-pci: Fix error path sign
Date: Thu, 16 Apr 2015 12:00:59 -0600	[thread overview]
Message-ID: <20150416180059.3224.64688.stgit@gimli.home> (raw)
In-Reply-To: <20150416175945.3224.58452.stgit@gimli.home>

This is an impossible error path due to the fact that we're reading a
kernel provided, rather than user provided link, which will certainly
always fit in PATH_MAX.  Currently it returns a fixed 26 char path
plus %d group number, which typically maxes out at double digits.
However, the caller of the initfn certainly expects a less-than zero
return value on error, not just a non-zero value.  Therefore we
should correct the sign here.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 hw/vfio/pci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index d387fbd..ebc1e0a 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3352,7 +3352,7 @@ static int vfio_initfn(PCIDevice *pdev)
     len = readlink(path, iommu_group_path, sizeof(path));
     if (len <= 0 || len >= sizeof(path)) {
         error_report("vfio: error no iommu_group for device");
-        return len < 0 ? -errno : ENAMETOOLONG;
+        return len < 0 ? -errno : -ENAMETOOLONG;
     }
 
     iommu_group_path[len] = 0;

  parent reply	other threads:[~2015-04-16 18:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16 18:00 [Qemu-devel] [PATCH for-2.4 0/2] vfio-pci: Fixes for fixes Alex Williamson
2015-04-16 18:00 ` [Qemu-devel] [PATCH for-2.4 1/2] vfio-pci: Further fix BAR size overflow Alex Williamson
2015-04-16 18:00 ` Alex Williamson [this message]
2015-04-16 18:17 ` [Qemu-devel] [PATCH for-2.4 0/2] vfio-pci: Fixes for fixes Laszlo Ersek

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=20150416180059.3224.64688.stgit@gimli.home \
    --to=alex.williamson@redhat.com \
    --cc=lersek@redhat.com \
    --cc=qemu-devel@nongnu.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).