From patchwork Fri Sep 18 00:57:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiejun Chen X-Patchwork-Id: 519088 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 EFA5C1402A1 for ; Fri, 18 Sep 2015 10:58:41 +1000 (AEST) Received: from localhost ([::1]:34299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zck0e-0002Jq-4w for incoming@patchwork.ozlabs.org; Thu, 17 Sep 2015 20:58:40 -0400 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 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 17 Sep 2015 17:58:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,549,1437462000"; d="scan'208";a="563927599" Received: from tchen0-linux.bj.intel.com ([10.238.135.75]) by FMSMGA003.fm.intel.com with ESMTP; 17 Sep 2015 17:58:19 -0700 From: Tiejun Chen To: qemu-devel@nongnu.org, xen-devel@lists.xen.org Date: Fri, 18 Sep 2015 08:57:10 +0800 Message-Id: <1442537830-7342-1-git-send-email-tiejun.chen@intel.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Cc: Paolo Bonzini , Stefano Stabellini , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] hw/pci-host/piix: fix one file descriptor leak 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 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; }