diff mbox series

[2/4] memfd: always check for MFD_CLOEXEC

Message ID 20181127111050.18453-3-i.maximets@samsung.com
State New
Headers show
Series memfd fixes. | expand

Commit Message

Ilya Maximets Nov. 27, 2018, 11:10 a.m. UTC
QEMU always sets this flag unconditionally. We need to
check if it's supported.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 util/memfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marc-André Lureau Nov. 27, 2018, 11:51 a.m. UTC | #1
On Tue, Nov 27, 2018 at 3:11 PM Ilya Maximets <i.maximets@samsung.com> wrote:
>
> QEMU always sets this flag unconditionally. We need to
> check if it's supported.
>
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>

I don't think that flag is optional, but it doesn't hurt to check it as well
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  util/memfd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/memfd.c b/util/memfd.c
> index 8debd0d037..d74ce4d793 100644
> --- a/util/memfd.c
> +++ b/util/memfd.c
> @@ -188,7 +188,7 @@ bool qemu_memfd_alloc_check(void)
>  bool qemu_memfd_check(unsigned int flags)
>  {
>  #ifdef CONFIG_LINUX
> -    int mfd = memfd_create("test", flags);
> +    int mfd = memfd_create("test", flags | MFD_CLOEXEC);
>
>      if (mfd >= 0) {
>          close(mfd);
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/util/memfd.c b/util/memfd.c
index 8debd0d037..d74ce4d793 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -188,7 +188,7 @@  bool qemu_memfd_alloc_check(void)
 bool qemu_memfd_check(unsigned int flags)
 {
 #ifdef CONFIG_LINUX
-    int mfd = memfd_create("test", flags);
+    int mfd = memfd_create("test", flags | MFD_CLOEXEC);
 
     if (mfd >= 0) {
         close(mfd);