Merge tag 'mm-stable-2024-05-17-19-19' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / fs / userfaultfd.c
index 2a564f813314300896b36fb2d5a48f9ae8eb38b9..eee7320ab0b028c31676a6f8e59f9748fecc9671 100644 (file)
@@ -658,7 +658,10 @@ int dup_userfaultfd(struct vm_area_struct *vma, struct list_head *fcs)
        struct userfaultfd_fork_ctx *fctx;
 
        octx = vma->vm_userfaultfd_ctx.ctx;
-       if (!octx || !(octx->features & UFFD_FEATURE_EVENT_FORK)) {
+       if (!octx)
+               return 0;
+
+       if (!(octx->features & UFFD_FEATURE_EVENT_FORK)) {
                vma_start_write(vma);
                vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
                userfaultfd_set_vm_flags(vma, vma->vm_flags & ~__VM_UFFD_FLAGS);