958e1b
From 56d77f768a5aa2b35ba645ae05d56e9908457c92 Mon Sep 17 00:00:00 2001
958e1b
Message-Id: <56d77f768a5aa2b35ba645ae05d56e9908457c92.1418766606.git.jen@redhat.com>
958e1b
In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
958e1b
References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
958e1b
From: Fam Zheng <famz@redhat.com>
958e1b
Date: Thu, 4 Dec 2014 00:05:23 -0600
958e1b
Subject: [CHANGE 29/31] vmdk: fix buf leak in vmdk_parse_extents()
958e1b
To: rhvirt-patches@redhat.com,
958e1b
    jen@redhat.com
958e1b
958e1b
RH-Author: Fam Zheng <famz@redhat.com>
958e1b
Message-id: <1417651524-18041-30-git-send-email-famz@redhat.com>
958e1b
Patchwork-id: 62702
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 29/30] vmdk: fix buf leak in vmdk_parse_extents()
958e1b
Bugzilla: 1002493
958e1b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
958e1b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
958e1b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
958e1b
958e1b
From: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
958e1b
vmdk_open_sparse() does not take ownership of buf so the caller always
958e1b
needs to free it.
958e1b
958e1b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
Reviewed-by: Max Reitz <mreitz@redhat.com>
958e1b
Reviewed-by: Fam Zheng <famz@redhat.com>
958e1b
(cherry picked from commit b6b1d31f098eef8cd13556d343e46c213fac972a)
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
958e1b
---
958e1b
 block/vmdk.c | 2 +-
958e1b
 1 file changed, 1 insertion(+), 1 deletion(-)
958e1b
958e1b
diff --git a/block/vmdk.c b/block/vmdk.c
958e1b
index ddd06f0..0593a1a 100644
958e1b
--- a/block/vmdk.c
958e1b
+++ b/block/vmdk.c
958e1b
@@ -847,8 +847,8 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
958e1b
             } else {
958e1b
                 ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, buf, errp);
958e1b
             }
958e1b
+            g_free(buf);
958e1b
             if (ret) {
958e1b
-                g_free(buf);
958e1b
                 bdrv_unref(extent_file);
958e1b
                 return ret;
958e1b
             }
958e1b
-- 
958e1b
2.1.0
958e1b