qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH for-2.4 2/2] vfio-pci: Fix error path sign


From: Alex Williamson
Subject: [Qemu-devel] [PATCH for-2.4 2/2] vfio-pci: Fix error path sign
Date: Thu, 16 Apr 2015 12:00:59 -0600
User-agent: StGit/0.17.1-dirty

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 <address@hidden>
Signed-off-by: Alex Williamson <address@hidden>
---
 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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]