fixed error handling


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2133 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/block.c b/block.c
index 885b700..3b35500 100644
--- a/block.c
+++ b/block.c
@@ -365,6 +365,8 @@
     }
     if (ret < 0) {
         qemu_free(bs->opaque);
+        bs->opaque = NULL;
+        bs->drv = NULL;
         return ret;
     }
     if (drv->bdrv_getlength) {
@@ -381,7 +383,7 @@
         if (!bs->backing_hd) {
         fail:
             bdrv_close(bs);
-            return -1;
+            return -ENOMEM;
         }
         path_combine(backing_filename, sizeof(backing_filename),
                      filename, bs->backing_file);