From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn9gc-00010d-8E for qemu-devel@nongnu.org; Tue, 28 Apr 2015 13:52:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn9gY-0005v0-Vt for qemu-devel@nongnu.org; Tue, 28 Apr 2015 13:52:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn9gY-0005uv-NW for qemu-devel@nongnu.org; Tue, 28 Apr 2015 13:52:42 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3SHqgtn026877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 28 Apr 2015 13:52:42 -0400 From: Alex Williamson Date: Tue, 28 Apr 2015 11:52:41 -0600 Message-ID: <20150428175241.22974.5127.stgit@gimli.home> In-Reply-To: <20150428175126.22974.5772.stgit@gimli.home> References: <20150428175126.22974.5772.stgit@gimli.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PULL 2/3] vfio-pci: Fix error path sign List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 Reviewed-by: Laszlo Ersek Signed-off-by: Alex Williamson --- 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 495f5fd..576c677 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -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;