summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2014-02-08 09:53:22 +0100
committerKevin Wolf <kwolf@redhat.com>2014-02-09 09:12:39 +0100
commiteaf944a43835399f12808aebd0d0a1db6249ed07 (patch)
treeb75a27d760a3729e8a9ecba39a4c21c46ba4b8a4 /block
parent5f5bcd80f8c365bca1480dc39141952fa7f88c71 (diff)
downloadqemu-eaf944a43835399f12808aebd0d0a1db6249ed07.zip
blkdebug: Don't leak bs->file on failure
Reported-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/blkdebug.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 56c4cd084f..8eb0db0723 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -396,14 +396,14 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
ret = -EINVAL;
- goto fail;
+ goto out;
}
/* Read rules from config file or command line options */
config = qemu_opt_get(opts, "config");
ret = read_config(s, config, options, errp);
if (ret) {
- goto fail;
+ goto out;
}
/* Set initial state */
@@ -414,7 +414,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
flags, true, false, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
- goto fail;
+ goto out;
}
/* Set request alignment */
@@ -424,11 +424,15 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
} else {
error_setg(errp, "Invalid alignment");
ret = -EINVAL;
- goto fail;
+ goto fail_unref;
}
ret = 0;
-fail:
+ goto out;
+
+fail_unref:
+ bdrv_unref(bs->file);
+out:
qemu_opts_del(opts);
return ret;
}