userfaultfd: add missing mmput() in error path
Subsystems (2)
PATCH 1/1 userfaultfd: add missing mmput() in error path
From: Eric Biggers <[email protected]>
This fixes a memleak if anon_inode_getfile() fails in userfaultfd().
Signed-off-by Eric Biggers <[email protected]>
Signed-off-by Andrea Arcangeli <[email protected]>
--- fs/userfaultfd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/userfaultfd.c +3 -1
@@ -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; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>