diff mbox series

[PULL,12/12] file-posix: Fix leaked fd in raw_open_common() error path

Message ID 20200717125510.238374-13-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,01/12] vvfat: set status to odd fixes | expand

Commit Message

Kevin Wolf July 17, 2020, 12:55 p.m. UTC
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20200717105426.51134-4-kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/file-posix.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

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