mm: migrate: fix double call of radix_tree_replace_slot()
[sfrench/cifs-2.6.git] / mm / gup.c
index 6afae32571cae669044319e8aa4438679e8a3b95..76af4cfeaf68149f365cf9b29bef64ebe6f1474b 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -531,7 +531,7 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
         * reCOWed by userspace write).
         */
        if ((ret & VM_FAULT_WRITE) && !(vma->vm_flags & VM_WRITE))
-               *flags |= FOLL_COW;
+               *flags |= FOLL_COW;
        return 0;
 }
 
@@ -1638,7 +1638,7 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end,
                                         PMD_SHIFT, next, write, pages, nr))
                                return 0;
                } else if (!gup_pte_range(pmd, addr, next, write, pages, nr))
-                               return 0;
+                       return 0;
        } while (pmdp++, addr = next, addr != end);
 
        return 1;
@@ -1740,7 +1740,9 @@ bool gup_fast_permitted(unsigned long start, int nr_pages, int write)
 
 /*
  * Like get_user_pages_fast() except it's IRQ-safe in that it won't fall back to
- * the regular GUP. It will only return non-negative values.
+ * the regular GUP.
+ * Note a difference with get_user_pages_fast: this always returns the
+ * number of pages pinned, 0 if no pages were pinned.
  */
 int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
                          struct page **pages)
@@ -1806,9 +1808,12 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
        len = (unsigned long) nr_pages << PAGE_SHIFT;
        end = start + len;
 
+       if (nr_pages <= 0)
+               return 0;
+
        if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
                                        (void __user *)start, len)))
-               return 0;
+               return -EFAULT;
 
        if (gup_fast_permitted(start, nr_pages, write)) {
                local_irq_disable();