MIPS: Make access_ok() sideeffect proof.
authorRalf Baechle <ralf@linux-mips.org>
Mon, 27 Apr 2009 13:31:34 +0000 (15:31 +0200)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 14 May 2009 12:50:27 +0000 (13:50 +0100)
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/uaccess.h

index 09ff5bb17445f1fb2cc5465310eddaa10b9951a6..42b9cec2ee9698bcc8dfec2895999bcd57a88eba 100644 (file)
 
 #define __access_mask get_fs().seg
 
-#define __access_ok(addr, size, mask)                                  \
-       (((signed long)((mask) & ((addr) | ((addr) + (size)) | __ua_size(size)))) == 0)
+#define __access_ok(addr, size, mask)                                                  \
+({                                                                                     \
+       const volatile void __user *__up = addr;                                        \
+       unsigned long __addr = (unsigned long) __up;                                    \
+       unsigned long __size = size;                                                    \
+       unsigned long __mask = mask;                                                    \
+       unsigned long __ok;                                                             \
+                                                                                       \
+       __ok = (signed long)(__mask & (__addr | (__addr + __size) |                     \
+               __ua_size(__size)));                                                    \
+       __ok == 0;                                                                      \
+})
 
 #define access_ok(type, addr, size)                                    \
-       likely(__access_ok((unsigned long)(addr), (size), __access_mask))
+       likely(__access_ok((addr), (size), __access_mask))
 
 /*
  * put_user: - Write a simple value into user space.