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>
This commit is contained in:
parent
62bef58a55
commit
c03e946fdd
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue