]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
file-posix: Fix leaked fd in raw_open_common() error path
authorKevin Wolf <kwolf@redhat.com>
Fri, 17 Jul 2020 10:54:26 +0000 (12:54 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 17 Jul 2020 12:20:57 +0000 (14:20 +0200)
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

index 996e45ab9556fe9e6bfeecfc974c7ccab659abf7..8cc39a1ef6185659fa99ad90ae3dd7224ad54397 100644 (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);
     }