Skip to content

Commit

Permalink
userfaultfd: add missing mmput() in error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Biggers authored and Linus Torvalds committed Sep 18, 2015
1 parent 62bef58 commit c03e946
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/userfaultfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c03e946

Please sign in to comment.