From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yio65-0006IK-6g for qemu-devel@nongnu.org; Thu, 16 Apr 2015 14:01:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yio62-0000cP-Bl for qemu-devel@nongnu.org; Thu, 16 Apr 2015 14:01:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yio62-0000cK-4W for qemu-devel@nongnu.org; Thu, 16 Apr 2015 14:01:02 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3GI10Fx023712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 16 Apr 2015 14:01:00 -0400 From: Alex Williamson Date: Thu, 16 Apr 2015 12:00:59 -0600 Message-ID: <20150416180059.3224.64688.stgit@gimli.home> In-Reply-To: <20150416175945.3224.58452.stgit@gimli.home> References: <20150416175945.3224.58452.stgit@gimli.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH for-2.4 2/2] vfio-pci: Fix error path sign List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: alex.williamson@redhat.com Cc: lersek@redhat.com, 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 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 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;