aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/block.c b/block.c
index 885b700236..3b35500b75 100644
--- a/block.c
+++ b/block.c
@@ -365,6 +365,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
}
if (ret < 0) {
qemu_free(bs->opaque);
+ bs->opaque = NULL;
+ bs->drv = NULL;
return ret;
}
if (drv->bdrv_getlength) {
@@ -381,7 +383,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
if (!bs->backing_hd) {
fail:
bdrv_close(bs);
- return -1;
+ return -ENOMEM;
}
path_combine(backing_filename, sizeof(backing_filename),
filename, bs->backing_file);