]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/frv/kernel/sys_frv.c
frv: fix mmap2 error handling
[linux-2.6-omap-h63xx.git] / arch / frv / kernel / sys_frv.c
index 26b3df32b9a7476a89dd2ee238f642a4bc2e73fa..baadc97f86278ff2060f64932d60977c80d04abc 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/fs.h>
 #include <linux/smp.h>
 #include <linux/sem.h>
 #include <linux/msg.h>
 #include <linux/file.h>
 #include <linux/utsname.h>
 #include <linux/syscalls.h>
+#include <linux/ipc.h>
 
 #include <asm/setup.h>
 #include <asm/uaccess.h>
-#include <asm/ipc.h>
-
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-asmlinkage long sys_pipe(unsigned long __user * fildes)
-{
-       int fd[2];
-       int error;
-
-       error = do_pipe(fd);
-       if (!error) {
-               if (copy_to_user(fildes, fd, 2*sizeof(int)))
-                       error = -EFAULT;
-       }
-       return error;
-}
 
 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
                          unsigned long prot, unsigned long flags,
@@ -51,22 +35,21 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
        int error = -EBADF;
        struct file * file = NULL;
 
-       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
-       if (!(flags & MAP_ANONYMOUS)) {
-               file = fget(fd);
-               if (!file)
-                       goto out;
-       }
-
        /* As with sparc32, make sure the shift for mmap2 is constant
           (12), no matter what PAGE_SIZE we have.... */
 
        /* But unlike sparc32, don't just silently break if we're
           trying to map something we can't */
-       if (pgoff & ((1<<(PAGE_SHIFT-12))-1))
+       if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
                return -EINVAL;
+       pgoff >>= PAGE_SHIFT - 12;
 
-       pgoff >>= (PAGE_SHIFT - 12);
+       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+       if (!(flags & MAP_ANONYMOUS)) {
+               file = fget(fd);
+               if (!file)
+                       goto out;
+       }
 
        down_write(&current->mm->mmap_sem);
        error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);