From patchwork Thu Sep 4 20:04:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 385999 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 6E08A14007B for ; Fri, 5 Sep 2014 06:05:52 +1000 (EST) Received: from localhost ([::1]:53910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPdHy-0001w4-Hl for incoming@patchwork.ozlabs.org; Thu, 04 Sep 2014 16:05:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPdHA-0000oj-6h for qemu-devel@nongnu.org; Thu, 04 Sep 2014 16:05:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPdH4-0003xg-2q for qemu-devel@nongnu.org; Thu, 04 Sep 2014 16:05:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPdH3-0003xc-Sh for qemu-devel@nongnu.org; Thu, 04 Sep 2014 16:04:54 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s84K4rsK012905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 4 Sep 2014 16:04:53 -0400 Received: from localhost (ovpn-112-58.ams2.redhat.com [10.36.112.58]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s84K4q2i030877; Thu, 4 Sep 2014 16:04:52 -0400 From: Stefan Hajnoczi To: Date: Thu, 4 Sep 2014 21:04:43 +0100 Message-Id: <1409861083-9634-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1409861083-9634-1-git-send-email-stefanha@redhat.com> References: <1409861083-9634-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 2/2] vmdk: fix buf leak in vmdk_parse_extents() 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 vmdk_open_sparse() does not take ownership of buf so the caller always needs to free it. Signed-off-by: Stefan Hajnoczi Reviewed-by: Max Reitz Reviewed-by: Fam Zheng --- block/vmdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/vmdk.c b/block/vmdk.c index 9bf28f3..a1cb911 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -846,8 +846,8 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, } else { ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, buf, errp); } + g_free(buf); if (ret) { - g_free(buf); bdrv_unref(extent_file); return ret; }