s390/gup: handle zero nr_pages case correctly
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Tue, 8 Oct 2013 07:29:09 +0000 (09:29 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 24 Oct 2013 15:17:01 +0000 (17:17 +0200)
If [__]get_user_pages_fast() gets called with nr_pages == 0, the current
code would walk the page tables and pin as many pages until the first
invalid pte (or the kernel crashed while writing struct page pointers to
the pages array).
So let's handle at least the nr_pages == 0 case correctly and exit early.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/mm/gup.c

index d3a2b819fa0bab713cfde8d030c1aaf265219c6a..639fce464008854cf3d23c22f6dcbe4a970add68 100644 (file)
@@ -180,7 +180,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
        addr = start;
        len = (unsigned long) nr_pages << PAGE_SHIFT;
        end = start + len;
-       if ((end < start) || (end > TASK_SIZE))
+       if ((end <= start) || (end > TASK_SIZE))
                return 0;
        /*
         * local_irq_save() doesn't prevent pagetable teardown, but does
This page took 0.030896 seconds and 5 git commands to generate.