return 0;
 }
 
+static inline bool vma_can_userfault(struct vm_area_struct *vma)
+{
+       return vma_is_anonymous(vma) || is_vm_hugetlb_page(vma);
+}
+
 static int userfaultfd_register(struct userfaultfd_ctx *ctx,
                                unsigned long arg)
 {
 
                /* check not compatible vmas */
                ret = -EINVAL;
-               if (!vma_is_anonymous(cur) && !is_vm_hugetlb_page(cur))
+               if (!vma_can_userfault(cur))
                        goto out_unlock;
                /*
                 * If this vma contains ending address, and huge pages
        do {
                cond_resched();
 
-               BUG_ON(!vma_is_anonymous(vma) && !is_vm_hugetlb_page(vma));
+               BUG_ON(!vma_can_userfault(vma));
                BUG_ON(vma->vm_userfaultfd_ctx.ctx &&
                       vma->vm_userfaultfd_ctx.ctx != ctx);
 
                 * provides for more strict behavior to notice
                 * unregistration errors.
                 */
-               if (!vma_is_anonymous(cur) && !is_vm_hugetlb_page(cur))
+               if (!vma_can_userfault(cur))
                        goto out_unlock;
 
                found = true;
        do {
                cond_resched();
 
-               BUG_ON(!vma_is_anonymous(vma) && !is_vm_hugetlb_page(vma));
+               BUG_ON(!vma_can_userfault(vma));
 
                /*
                 * Nothing to do: this vma is already registered into this