Commit c03e946f authored by Eric Biggers's avatar Eric Biggers Committed by Linus Torvalds

userfaultfd: add missing mmput() in error path

This fixes a memleak if anon_inode_getfile() fails in userfaultfd().
Signed-off-by: default avatarEric Biggers <ebiggers3@gmail.com>
Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 62bef58a
...@@ -1287,8 +1287,10 @@ static struct file *userfaultfd_file_create(int flags) ...@@ -1287,8 +1287,10 @@ static struct file *userfaultfd_file_create(int flags)
file = anon_inode_getfile("[userfaultfd]", &userfaultfd_fops, ctx, file = anon_inode_getfile("[userfaultfd]", &userfaultfd_fops, ctx,
O_RDWR | (flags & UFFD_SHARED_FCNTL_FLAGS)); O_RDWR | (flags & UFFD_SHARED_FCNTL_FLAGS));
if (IS_ERR(file)) if (IS_ERR(file)) {
mmput(ctx->mm);
kmem_cache_free(userfaultfd_ctx_cachep, ctx); kmem_cache_free(userfaultfd_ctx_cachep, ctx);
}
out: out:
return file; return file;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment