958e1b
From 9602ee8eaedf151648fd8e47ce4673799ea567c3 Mon Sep 17 00:00:00 2001
958e1b
Message-Id: <9602ee8eaedf151648fd8e47ce4673799ea567c3.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:16 -0600
958e1b
Subject: [CHANGE 22/31] vmdk: Fix local_err in vmdk_create
958e1b
To: rhvirt-patches@redhat.com,
958e1b
    jen@redhat.com
958e1b
958e1b
RH-Author: Fam Zheng <famz@redhat.com>
958e1b
Message-id: <1417651524-18041-23-git-send-email-famz@redhat.com>
958e1b
Patchwork-id: 62695
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 22/30] vmdk: Fix local_err in vmdk_create
958e1b
Bugzilla: 1134283
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
In vmdk_create and vmdk_create_extent, initialize local_err before using
958e1b
it, and don't leak it on error.
958e1b
958e1b
Reported-by: Markus Armbruster <armbru@redhat.com>
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
Reviewed-by: Markus Armbruster <armbru@redhat.com>
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
(cherry picked from commit c13959c745a7e4965c94d19e3153d2c44459906d)
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
958e1b
---
958e1b
 block/vmdk.c | 8 ++++----
958e1b
 1 file changed, 4 insertions(+), 4 deletions(-)
958e1b
958e1b
diff --git a/block/vmdk.c b/block/vmdk.c
958e1b
index 94e8782..a625e7a 100644
958e1b
--- a/block/vmdk.c
958e1b
+++ b/block/vmdk.c
958e1b
@@ -1533,7 +1533,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
958e1b
     int ret, i;
958e1b
     BlockDriverState *bs = NULL;
958e1b
     VMDK4Header header;
958e1b
-    Error *local_err;
958e1b
+    Error *local_err = NULL;
958e1b
     uint32_t tmp, magic, grains, gd_sectors, gt_size, gt_count;
958e1b
     uint32_t *gd_buf = NULL;
958e1b
     int gd_buf_size;
958e1b
@@ -1697,7 +1697,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
958e1b
 {
958e1b
     int idx = 0;
958e1b
     BlockDriverState *new_bs = NULL;
958e1b
-    Error *local_err;
958e1b
+    Error *local_err = NULL;
958e1b
     char *desc = NULL;
958e1b
     int64_t total_size = 0, filesize;
958e1b
     const char *adapter_type = NULL;
958e1b
@@ -1878,13 +1878,13 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
958e1b
     } else {
958e1b
         ret = bdrv_create_file(filename, options, &local_err);
958e1b
         if (ret < 0) {
958e1b
-            error_setg_errno(errp, -ret, "Could not create image file");
958e1b
+            error_propagate(errp, local_err);
958e1b
             goto exit;
958e1b
         }
958e1b
     }
958e1b
     ret = bdrv_file_open(&new_bs, filename, NULL, BDRV_O_RDWR, &local_err);
958e1b
     if (ret < 0) {
958e1b
-        error_setg_errno(errp, -ret, "Could not write description");
958e1b
+        error_propagate(errp, local_err);
958e1b
         goto exit;
958e1b
     }
958e1b
     ret = bdrv_pwrite(new_bs, desc_offset, desc, desc_len);
958e1b
-- 
958e1b
2.1.0
958e1b