Commit 6b21b973ab9aa2bfc3ebfe1df4474466ceb4d88b
1 parent
2192c332
fixed error handling
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2133 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
3 additions
and
1 deletions
block.c
@@ -365,6 +365,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | @@ -365,6 +365,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | ||
365 | } | 365 | } |
366 | if (ret < 0) { | 366 | if (ret < 0) { |
367 | qemu_free(bs->opaque); | 367 | qemu_free(bs->opaque); |
368 | + bs->opaque = NULL; | ||
369 | + bs->drv = NULL; | ||
368 | return ret; | 370 | return ret; |
369 | } | 371 | } |
370 | if (drv->bdrv_getlength) { | 372 | if (drv->bdrv_getlength) { |
@@ -381,7 +383,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | @@ -381,7 +383,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | ||
381 | if (!bs->backing_hd) { | 383 | if (!bs->backing_hd) { |
382 | fail: | 384 | fail: |
383 | bdrv_close(bs); | 385 | bdrv_close(bs); |
384 | - return -1; | 386 | + return -ENOMEM; |
385 | } | 387 | } |
386 | path_combine(backing_filename, sizeof(backing_filename), | 388 | path_combine(backing_filename, sizeof(backing_filename), |
387 | filename, bs->backing_file); | 389 | filename, bs->backing_file); |