yeahuh / rpms / qemu-kvm

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