]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vfio-pci: Fix error path sign
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 28 Apr 2015 17:14:02 +0000 (11:14 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 28 Apr 2015 17:14:02 +0000 (11:14 -0600)
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>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/pci.c

index 495f5fda8e8bee169cc164c29a37aea58acc2645..576c677be37802147d07384ab62899bb91957bf0 100644 (file)
@@ -3358,7 +3358,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;