From patchwork Sat Mar 14 09:52:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 450181 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 411EB1400A0 for ; Sat, 14 Mar 2015 20:53:18 +1100 (AEDT) Received: from localhost ([::1]:40224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWiku-00019g-H9 for incoming@patchwork.ozlabs.org; Sat, 14 Mar 2015 05:53:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWikY-0000aT-TG for qemu-devel@nongnu.org; Sat, 14 Mar 2015 05:52:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWikX-0005QL-OJ for qemu-devel@nongnu.org; Sat, 14 Mar 2015 05:52:54 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:35224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWikS-0005Oo-6f; Sat, 14 Mar 2015 05:52:48 -0400 Received: from 172.24.2.119 (EHLO szxeml431-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CIL94439; Sat, 14 Mar 2015 17:52:33 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.158.1; Sat, 14 Mar 2015 17:52:24 +0800 From: Shannon Zhao To: Date: Sat, 14 Mar 2015 17:52:15 +0800 Message-ID: <1426326735-11448-1-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: peter.maydell@linaro.org, hangaohuai@huawei.com, zhang.zhanghailiang@huawei.com, qemu-trivial@nongnu.org, sw@weilnetz.de, mjt@tls.msk.ru, mdroth@linux.vnet.ibm.com, peter.huangpeng@huawei.com, shannon.zhao@linaro.org, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v2] qga/commands-posix: Fix resource 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 It's detected by coverity. Close the dirfd. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Stefan Weil Reviewed-by: zhanghailiang --- v1->v2: close after use [Stefan Weil] --- qga/commands-posix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index d5bb5cb..ba8de62 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2283,6 +2283,7 @@ GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp) buf = g_malloc0(20); ga_read_sysfs_file(dirfd, "block_size_bytes", buf, 20, &local_err); + close(dirfd); if (local_err) { g_free(buf); error_propagate(errp, local_err);