powerpc/mm: Fix mmap errno when MAP_FIXED is set and mapping exceeds the allowed...
authorjmarchan@redhat.com <jmarchan@redhat.com>
Wed, 15 Jan 2014 15:27:11 +0000 (16:27 +0100)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 29 Jan 2014 06:02:25 +0000 (17:02 +1100)
According to Posix, if MAP_FIXED is specified mmap shall set ENOMEM if
the requested mapping exceeds the allowed range for address space of
the process. The generic code set it right, but the specific powerpc
slice_get_unmapped_area() function currently returns -EINVAL in that
case.
This patch corrects it.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/mm/slice.c

index 7ce9cf3..b0c75cc 100644 (file)
@@ -408,7 +408,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
        if (fixed && (addr & ((1ul << pshift) - 1)))
                return -EINVAL;
        if (fixed && addr > (mm->task_size - len))
-               return -EINVAL;
+               return -ENOMEM;
 
        /* If hint, make sure it matches our alignment restrictions */
        if (!fixed && addr) {