From patchwork Tue Apr 28 17:52:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 465725 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A90EE14012C for ; Wed, 29 Apr 2015 03:54:15 +1000 (AEST) Received: from localhost ([::1]:35296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn9i0-00035V-EB for incoming@patchwork.ozlabs.org; Tue, 28 Apr 2015 13:54:12 -0400 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 Received: from gimli.home (ovpn-113-195.phx2.redhat.com [10.3.113.195]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3SHqfom021135; Tue, 28 Apr 2015 13:52:41 -0400 From: Alex Williamson To: qemu-devel@nongnu.org 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> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/3] vfio-pci: Fix error path sign X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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;