yeahuh / rpms / qemu-kvm

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