fixed error handling

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2133 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2006-08-23 21:14:37 +00:00
parent 2192c33250
commit 6b21b973ab

View File

@ -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);