aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2020-07-17 12:54:26 +0200
committerKevin Wolf <kwolf@redhat.com>2020-07-17 14:20:57 +0200
commita8c5cf27c945d392edd85b0b0c64cd5c52cae658 (patch)
treedf5f285a1eae977f5c548d80d5bb9c450ded8e59 /block
parentbca5283bd4a086bcbfaddc024491a400cc9b2fa9 (diff)
downloadqemu-a8c5cf27c945d392edd85b0b0c64cd5c52cae658.zip
qemu-a8c5cf27c945d392edd85b0b0c64cd5c52cae658.tar.gz
qemu-a8c5cf27c945d392edd85b0b0c64cd5c52cae658.tar.bz2
file-posix: Fix leaked fd in raw_open_common() error path
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>
Diffstat (limited to 'block')
-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 996e45a..8cc39a1 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);
}