From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zck0P-000227-IX for qemu-devel@nongnu.org; Thu, 17 Sep 2015 20:58:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zck0M-0006Ge-Ce for qemu-devel@nongnu.org; Thu, 17 Sep 2015 20:58:25 -0400 Received: from mga03.intel.com ([134.134.136.65]:53281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zck0M-0006GG-7Z for qemu-devel@nongnu.org; Thu, 17 Sep 2015 20:58:22 -0400 From: Tiejun Chen Date: Fri, 18 Sep 2015 08:57:10 +0800 Message-Id: <1442537830-7342-1-git-send-email-tiejun.chen@intel.com> Subject: [Qemu-devel] [PATCH] hw/pci-host/piix: fix one file descriptor leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, xen-devel@lists.xen.org Cc: Paolo Bonzini , Stefano Stabellini , "Michael S. Tsirkin" Commit 595a4f07d6bd (piix: create host bridge to passthrough) introduced to leak of one file descriptor, "config_fd", now just fix that. CC: Michael S. Tsirkin CC: Stefano Stabellini CC: Paolo Bonzini Acked-by: Stefano Stabellini Signed-off-by: Tiejun Chen --- hw/pci-host/piix.c | 3 +++ 1 file changed, 3 insertions(+) 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; } -- 1.9.1