summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers3@gmail.com>2015-09-18 01:01:54 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-18 06:16:07 +0200
commitc03e946fdd653c4a23e242aca83da7e9838f5b00 (patch)
treef3b2987c0f9ff231cf64bf2bcfb93aa9fc9e105a
parentlib/string_helpers.c: fix infinite loop in string_get_size() (diff)
downloadlinux-c03e946fdd653c4a23e242aca83da7e9838f5b00.tar.xz
linux-c03e946fdd653c4a23e242aca83da7e9838f5b00.zip
userfaultfd: add missing mmput() in error path
This fixes a memleak if anon_inode_getfile() fails in userfaultfd(). Signed-off-by: Eric Biggers <ebiggers3@gmail.com> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/userfaultfd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 634e676072cb..f9aeb40a7197 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1287,8 +1287,10 @@ static struct file *userfaultfd_file_create(int flags)
file = anon_inode_getfile("[userfaultfd]", &userfaultfd_fops, ctx,
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);
+ }
out:
return file;
}