]> git.proxmox.com Git - mirror_qemu.git/commit
memfd: fix possible usage of the uninitialized file descriptor
authorDima Stepanov <dimastep@yandex-team.ru>
Wed, 13 Jun 2018 08:19:54 +0000 (11:19 +0300)
committerThomas Huth <thuth@redhat.com>
Tue, 25 Sep 2018 15:26:18 +0000 (17:26 +0200)
commit1e7ec6cf067025552bb10def7c49f4527d2f035f
tree2d70a6908abe8cf382eebdd98f78d2dd7ceedc9f
parent91c082ad86e96ee342faaa024d46fd3e6242a98e
memfd: fix possible usage of the uninitialized file descriptor

The qemu_memfd_alloc_check() routine allocates the fd variable on stack.
This variable is initialized inside the qemu_memfd_alloc() function.
There are several cases when *fd will be left unintialized which can
lead to the unexpected close() in the qemu_memfd_free() call.

Set file descriptor to -1 before calling the qemu_memfd_alloc routine.

Signed-off-by: Dima Stepanov <dimastep@yandex-team.ru>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
util/memfd.c