Blob Blame History Raw
From 56d77f768a5aa2b35ba645ae05d56e9908457c92 Mon Sep 17 00:00:00 2001
Message-Id: <56d77f768a5aa2b35ba645ae05d56e9908457c92.1418766606.git.jen@redhat.com>
In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
From: Fam Zheng <famz@redhat.com>
Date: Thu, 4 Dec 2014 00:05:23 -0600
Subject: [CHANGE 29/31] vmdk: fix buf leak in vmdk_parse_extents()
To: rhvirt-patches@redhat.com,
    jen@redhat.com

RH-Author: Fam Zheng <famz@redhat.com>
Message-id: <1417651524-18041-30-git-send-email-famz@redhat.com>
Patchwork-id: 62702
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 29/30] vmdk: fix buf leak in vmdk_parse_extents()
Bugzilla: 1002493
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>

From: Stefan Hajnoczi <stefanha@redhat.com>

vmdk_open_sparse() does not take ownership of buf so the caller always
needs to free it.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
(cherry picked from commit b6b1d31f098eef8cd13556d343e46c213fac972a)
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
---
 block/vmdk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index ddd06f0..0593a1a 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -847,8 +847,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;
             }
-- 
2.1.0