From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc1Fx-0000Fd-OD for qemu-devel@nongnu.org; Tue, 15 Sep 2015 21:11:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc1Fs-0000Pm-QD for qemu-devel@nongnu.org; Tue, 15 Sep 2015 21:11:29 -0400 Received: from mga09.intel.com ([134.134.136.24]:60840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc1Fs-0000LC-KH for qemu-devel@nongnu.org; Tue, 15 Sep 2015 21:11:24 -0400 References: <55F0DB30.6070607@intel.com> <55F14E20.6070805@intel.com> <55F69A18.20709@redhat.com> <55F7FA43.40600@redhat.com> From: "Chen, Tiejun" Message-ID: <55F8C1B8.6060509@intel.com> Date: Wed, 16 Sep 2015 09:11:20 +0800 MIME-Version: 1.0 In-Reply-To: <55F7FA43.40600@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL 0/19] xen-2015-09-08-tag List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Stefano Stabellini Cc: Peter Maydell , "xen-devel@lists.xensource.com Devel" , QEMU Developers , mst@redhat.com On 9/15/2015 7:00 PM, Paolo Bonzini wrote: > > > On 15/09/2015 11:55, Stefano Stabellini wrote: >> On Mon, 14 Sep 2015, Paolo Bonzini wrote: >>> > On 10/09/2015 12:29, Stefano Stabellini wrote: >>>> > > + if (lseek(config_fd, pos, SEEK_SET) != pos) { >>>> > > + return -errno; >>>> > > + } >>>> > > do { >>>> > > - rc = pread(config_fd, (uint8_t *)&val, len, pos); >>>> > > + rc = read(config_fd, (uint8_t *)&val, len); >>>> > > } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); >>> > >>> > This leaks config_fd. >> I don't follow, it leaks config_fd where? > > Where lseek returns -errno (and IIRC in other places in the same function). Do you mean we need this change? diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index 1fb71c8..7d44228 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -775,15 +775,18 @@ static int host_pci_config_read(int pos, int len, uint32_t val) } if (lseek(config_fd, pos, SEEK_SET) != pos) { + close(config_fd); return -errno; } do { rc = read(config_fd, (uint8_t *)&val, len); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); if (rc != len) { + close(config_fd); return -errno; } + close(config_fd); return 0; } Thanks Tiejun