summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--block/file-posix.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/file-posix.c b/block/file-posix.c
index 996e45ab95..8cc39a1ef6 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -773,6 +773,9 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
     }
     ret = 0;
 fail:
+    if (ret < 0 && s->fd != -1) {
+        qemu_close(s->fd);
+    }
     if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
         unlink(filename);
     }