userfaultfd: use mmgrab instead of open-coded increment of mm_count
authorMike Rapoport <rppt@linux.vnet.ibm.com>
Thu, 16 Nov 2017 01:36:56 +0000 (17:36 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 Nov 2017 02:21:05 +0000 (18:21 -0800)
Link: http://lkml.kernel.org/r/1508132478-7738-1-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/userfaultfd.c

index f46d133c094998c48eada7a4e2bd8f5a69239ffa..ac9a4e65ca497ad3b673dc50893d13b44150c70f 100644 (file)
@@ -668,7 +668,7 @@ int dup_userfaultfd(struct vm_area_struct *vma, struct list_head *fcs)
                ctx->features = octx->features;
                ctx->released = false;
                ctx->mm = vma->vm_mm;
-               atomic_inc(&ctx->mm->mm_count);
+               mmgrab(ctx->mm);
 
                userfaultfd_ctx_get(octx);
                fctx->orig = octx;