Skip to content

Commit

Permalink
s390/gup: handle zero nr_pages case correctly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heiko Carstens authored and Martin Schwidefsky committed Oct 24, 2013
1 parent 01997bb commit eb0bf92
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/s390/mm/gup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb0bf92

Please sign in to comment.