From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjD7h-0002e1-Bx for qemu-devel@nongnu.org; Fri, 06 Jan 2012 11:58:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RjD7g-00022j-14 for qemu-devel@nongnu.org; Fri, 06 Jan 2012 11:58:33 -0500 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:57557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjD7f-00022a-Op for qemu-devel@nongnu.org; Fri, 06 Jan 2012 11:58:31 -0500 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 6 Jan 2012 16:58:30 -0000 From: Stefan Hajnoczi Date: Fri, 6 Jan 2012 16:57:44 +0000 Message-Id: <1325869065-32182-2-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1325869065-32182-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1325869065-32182-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 1/2] vvfat: avoid leaking file descriptor in commit_one_file() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Stefan Hajnoczi Reported-by: Dr David Alan Gilbert Signed-off-by: Stefan Hajnoczi --- block/vvfat.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index eeffc4a..9ef21dd 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2218,6 +2218,7 @@ static int commit_one_file(BDRVVVFATState* s, } if (offset > 0) { if (lseek(fd, offset, SEEK_SET) != offset) { + close(fd); g_free(cluster); return -3; } @@ -2238,11 +2239,13 @@ static int commit_one_file(BDRVVVFATState* s, (uint8_t*)cluster, (rest_size + 0x1ff) / 0x200); if (ret < 0) { + close(fd); g_free(cluster); return ret; } if (write(fd, cluster, rest_size) < 0) { + close(fd); g_free(cluster); return -2; } -- 1.7.7.3