From patchwork Thu May 30 14:14:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 247612 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AA07A2C0085 for ; Fri, 31 May 2013 00:16:07 +1000 (EST) Received: from localhost ([::1]:39874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui3e9-0006cf-QQ for incoming@patchwork.ozlabs.org; Thu, 30 May 2013 10:16:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui3dB-0006IE-E5 for qemu-devel@nongnu.org; Thu, 30 May 2013 10:15:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ui3d5-0003wg-6u for qemu-devel@nongnu.org; Thu, 30 May 2013 10:15:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui3d4-0003wb-WD; Thu, 30 May 2013 10:14:59 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4UEEwna002598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 30 May 2013 10:14:58 -0400 Received: from localhost (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r4UEEvqj006708; Thu, 30 May 2013 10:14:57 -0400 From: Stefan Hajnoczi To: Date: Thu, 30 May 2013 16:14:46 +0200 Message-Id: <1369923286-22260-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1369923286-22260-1-git-send-email-stefanha@redhat.com> References: <1369923286-22260-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-stable@nongnu.org, Markus Armbruster , Stefan Hajnoczi , Juan Quintela Subject: [Qemu-devel] [PATCH 3/3] savevm: avoid leaking popen(3) file pointer 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 I'm not sure why we check the mode only after invoking popen(3) but we need to close the file pointer. Spotted by Coverity. Cc: Juan Quintela Cc: qemu-stable@nongnu.org Signed-off-by: Stefan Hajnoczi --- savevm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/savevm.c b/savevm.c index 31dcce9..75cc72e 100644 --- a/savevm.c +++ b/savevm.c @@ -329,6 +329,7 @@ QEMUFile *qemu_popen_cmd(const char *command, const char *mode) if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) { fprintf(stderr, "qemu_popen: Argument validity check failed\n"); + fclose(stdio_file); return NULL; }