05bba0
From ad2855430b1fcbd4566af464120892a32ce7d9f8 Mon Sep 17 00:00:00 2001
05bba0
From: Alex Williamson <alex.williamson@redhat.com>
05bba0
Date: Fri, 1 May 2015 18:10:44 +0200
05bba0
Subject: [PATCH 10/14] vfio-pci: Fix error path sign
05bba0
05bba0
Message-id: <20150501180951.31395.33354.stgit@gimli.home>
05bba0
Patchwork-id: 64973
05bba0
O-Subject: [RHEL7.2 qemu-kvm PATCH 10/8] vfio-pci: Fix error path sign
05bba0
Bugzilla: 1210504
05bba0
RH-Acked-by: Bandan Das <bsd@redhat.com>
05bba0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
05bba0
This is an impossible error path due to the fact that we're reading a
05bba0
kernel provided, rather than user provided link, which will certainly
05bba0
always fit in PATH_MAX.  Currently it returns a fixed 26 char path
05bba0
plus %d group number, which typically maxes out at double digits.
05bba0
However, the caller of the initfn certainly expects a less-than zero
05bba0
return value on error, not just a non-zero value.  Therefore we
05bba0
should correct the sign here.
05bba0
05bba0
Reported-by: Laszlo Ersek <lersek@redhat.com>
05bba0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
05bba0
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 hw/misc/vfio.c | 2 +-
05bba0
 1 file changed, 1 insertion(+), 1 deletion(-)
05bba0
05bba0
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
05bba0
index e6f96db..118489c 100644
05bba0
--- a/hw/misc/vfio.c
05bba0
+++ b/hw/misc/vfio.c
05bba0
@@ -3870,7 +3870,7 @@ static int vfio_initfn(PCIDevice *pdev)
05bba0
     len = readlink(path, iommu_group_path, sizeof(path));
05bba0
     if (len <= 0 || len >= sizeof(path)) {
05bba0
         error_report("vfio: error no iommu_group for device");
05bba0
-        return len < 0 ? -errno : ENAMETOOLONG;
05bba0
+        return len < 0 ? -errno : -ENAMETOOLONG;
05bba0
     }
05bba0
 
05bba0
     iommu_group_path[len] = 0;
05bba0
-- 
05bba0
1.8.3.1
05bba0