Skip to content

Commit a8c5cf2

Browse files
committed
file-posix: Fix leaked fd in raw_open_common() error path
Signed-off-by: Kevin Wolf <[email protected]> Message-Id: <[email protected]> Reviewed-by: Max Reitz <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent bca5283 commit a8c5cf2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/file-posix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,9 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
773773
}
774774
ret = 0;
775775
fail:
776+
if (ret < 0 && s->fd != -1) {
777+
qemu_close(s->fd);
778+
}
776779
if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
777780
unlink(filename);
778781
}

0 commit comments

Comments
 (0)