Signed-off-by: Kevin Wolf <kw...@redhat.com> --- block/blkdebug.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c index 56c4cd0..519b483 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -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 fail_unref; } /* Set request alignment */ @@ -424,10 +424,13 @@ 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; + return 0; + +fail_unref: + bdrv_unref(bs->file); fail: qemu_opts_del(opts); return ret; -- 1.8.1.4