cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 66e996f40abbca9c62a262beeefb93b7b4c6e64f Mon Sep 17 00:00:00 2001
0a122b
From: Kevin Wolf <kwolf@redhat.com>
0a122b
Date: Sat, 8 Feb 2014 09:53:22 +0100
0a122b
Subject: [PATCH 32/37] blkdebug: Don't leak bs->file on failure
0a122b
0a122b
Message-id: <1392117622-28812-33-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: 57197
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 32/37] blkdebug: Don't leak bs->file on failure
0a122b
Bugzilla: 748906
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
0a122b
0a122b
Reported-by: Laszlo Ersek <lersek@redhat.com>
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
0a122b
0a122b
Conflicts:
0a122b
	block/blkdebug.c
0a122b
0a122b
Conflicts because RHEL 7 doesn't have the blockdev-add support
0a122b
series for blkdebug.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 block/blkdebug.c | 16 ++++++++++------
0a122b
 1 file changed, 10 insertions(+), 6 deletions(-)
0a122b
---
0a122b
 block/blkdebug.c |   16 ++++++++++------
0a122b
 1 files changed, 10 insertions(+), 6 deletions(-)
0a122b
0a122b
diff --git a/block/blkdebug.c b/block/blkdebug.c
0a122b
index ccb562b..1e772a5 100644
0a122b
--- a/block/blkdebug.c
0a122b
+++ b/block/blkdebug.c
0a122b
@@ -367,7 +367,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
0a122b
     if (error_is_set(&local_err)) {
0a122b
         error_propagate(errp, local_err);
0a122b
         ret = -EINVAL;
0a122b
-        goto fail;
0a122b
+        goto out;
0a122b
     }
0a122b
 
0a122b
     /* Read rules from config file */
0a122b
@@ -376,7 +376,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
0a122b
         ret = read_config(s, config);
0a122b
         if (ret < 0) {
0a122b
             error_setg_errno(errp, -ret, "Could not read blkdebug config file");
0a122b
-            goto fail;
0a122b
+            goto out;
0a122b
         }
0a122b
     }
0a122b
 
0a122b
@@ -388,13 +388,13 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
0a122b
     if (filename == NULL) {
0a122b
         error_setg(errp, "Could not retrieve image file name");
0a122b
         ret = -EINVAL;
0a122b
-        goto fail;
0a122b
+        goto out;
0a122b
     }
0a122b
 
0a122b
     ret = bdrv_file_open(&bs->file, filename, NULL, flags, &local_err);
0a122b
     if (ret < 0) {
0a122b
         error_propagate(errp, local_err);
0a122b
-        goto fail;
0a122b
+        goto out;
0a122b
     }
0a122b
 
0a122b
     /* Set request alignment */
0a122b
@@ -404,11 +404,15 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
0a122b
     } else {
0a122b
         error_setg(errp, "Invalid alignment");
0a122b
         ret = -EINVAL;
0a122b
-        goto fail;
0a122b
+        goto fail_unref;
0a122b
     }
0a122b
 
0a122b
     ret = 0;
0a122b
-fail:
0a122b
+    goto out;
0a122b
+
0a122b
+fail_unref:
0a122b
+    bdrv_unref(bs->file);
0a122b
+out:
0a122b
     qemu_opts_del(opts);
0a122b
     return ret;
0a122b
 }
0a122b
-- 
0a122b
1.7.1
0a122b