diff --git a/block/blkdebug.c b/block/blkdebug.c index 56c4cd0..1a8ccc4 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 done; } /* 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 done; } /* 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 done; } /* Set request alignment */ @@ -423,12 +423,13 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, bs->request_alignment = align; } else { error_setg(errp, "Invalid alignment"); + bdrv_unref(bs->file); ret = -EINVAL; - goto fail; + goto done; } ret = 0; -fail: +done: qemu_opts_del(opts); return ret; }