From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCCC3-0005Tt-Ro for qemu-devel@nongnu.org; Mon, 06 Jul 2015 15:36:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCCBy-0001yq-SV for qemu-devel@nongnu.org; Mon, 06 Jul 2015 15:36:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCCBy-0001y2-Ni for qemu-devel@nongnu.org; Mon, 06 Jul 2015 15:36:38 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C3A2E2635 for ; Mon, 6 Jul 2015 19:36:37 +0000 (UTC) From: Alex Williamson Date: Mon, 06 Jul 2015 12:34:43 -0600 Message-ID: <20150706183443.15635.49464.stgit@gimli.home> In-Reply-To: <20150706183311.15635.76314.stgit@gimli.home> References: <20150706183311.15635.76314.stgit@gimli.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PULL 01/11] vfio: fix return type of pread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Paolo Bonzini size_t is an unsigned type, thus the error case is never reached in the below call to pread. If bytes is negative, it will be seen as a very high positive value. Spotted by Coverity. Signed-off-by: Paolo Bonzini 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 e0e339a..b8fa4ac 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -939,7 +939,7 @@ static void vfio_pci_load_rom(VFIOPCIDevice *vdev) }; uint64_t size; off_t off = 0; - size_t bytes; + ssize_t bytes; if (ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) { error_report("vfio: Error getting ROM info: %m");