From patchwork Thu Apr 16 18:00:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 461826 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 A38691402FD for ; Fri, 17 Apr 2015 04:01:26 +1000 (AEST) Received: from localhost ([::1]:38027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yio6N-0006aW-IT for incoming@patchwork.ozlabs.org; Thu, 16 Apr 2015 14:01:23 -0400 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 Received: from gimli.home (ovpn-113-195.phx2.redhat.com [10.3.113.195]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3GI0xmm019779; Thu, 16 Apr 2015 14:00:59 -0400 From: Alex Williamson To: alex.williamson@redhat.com 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> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: lersek@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH for-2.4 2/2] 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 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;