diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/nommu.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index 8bdde9508f3b..6a2a8aada401 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -497,15 +497,17 @@ static int validate_mmap_request(struct file *file, | |||
497 | (flags & MAP_TYPE) != MAP_SHARED) | 497 | (flags & MAP_TYPE) != MAP_SHARED) |
498 | return -EINVAL; | 498 | return -EINVAL; |
499 | 499 | ||
500 | if (PAGE_ALIGN(len) == 0) | 500 | if (!len) |
501 | return addr; | ||
502 | |||
503 | if (len > TASK_SIZE) | ||
504 | return -EINVAL; | 501 | return -EINVAL; |
505 | 502 | ||
503 | /* Careful about overflows.. */ | ||
504 | len = PAGE_ALIGN(len); | ||
505 | if (!len || len > TASK_SIZE) | ||
506 | return -ENOMEM; | ||
507 | |||
506 | /* offset overflow? */ | 508 | /* offset overflow? */ |
507 | if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) | 509 | if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) |
508 | return -EINVAL; | 510 | return -EOVERFLOW; |
509 | 511 | ||
510 | if (file) { | 512 | if (file) { |
511 | /* validate file mapping requests */ | 513 | /* validate file mapping requests */ |