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>
This commit is contained in:
Kevin Wolf 2020-07-17 12:54:26 +02:00
parent bca5283bd4
commit a8c5cf27c9

View File

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