From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui8cd-0002A6-0p for qemu-devel@nongnu.org; Thu, 30 May 2013 15:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ui8cY-00037F-AA for qemu-devel@nongnu.org; Thu, 30 May 2013 15:34:50 -0400 MIME-Version: 1.0 In-Reply-To: <51A76145.1010304@redhat.com> References: <1369923286-22260-1-git-send-email-stefanha@redhat.com> <1369923286-22260-4-git-send-email-stefanha@redhat.com> <51A76145.1010304@redhat.com> Date: Thu, 30 May 2013 21:34:45 +0200 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] [PATCH 3/3] savevm: avoid leaking popen(3) file pointer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel , qemu-stable , Markus Armbruster , Stefan Hajnoczi , Juan Quintela On Thu, May 30, 2013 at 4:25 PM, Eric Blake wrote: > On 05/30/2013 08:14 AM, Stefan Hajnoczi wrote: >> 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); > > You MUST use pclose() (not fclose) on any FILE obtained by popen(), to > avoid resource leaks. Thanks, I didn't know that. Should have checked the popen(3) man page. Will fix. Stefan