sparc64: Prepare to move to more saner user copy exception handling.
[firefly-linux-kernel-4.4.55.git] / arch / sparc / include / asm / uaccess_64.h
index a17b8c4b189f64616ecd15bc78794eb2fb1f58d1..00a9fb89588736deddd75a97c4ffe8c6773dae21 100644 (file)
@@ -211,8 +211,11 @@ copy_from_user(void *to, const void __user *from, unsigned long size)
 {
        unsigned long ret = ___copy_from_user(to, from, size);
 
-       if (unlikely(ret))
-               ret = copy_from_user_fixup(to, from, size);
+       if (unlikely(ret)) {
+               if ((long)ret < 0)
+                       ret = copy_from_user_fixup(to, from, size);
+               return ret;
+       }
 
        return ret;
 }
@@ -228,8 +231,11 @@ copy_to_user(void __user *to, const void *from, unsigned long size)
 {
        unsigned long ret = ___copy_to_user(to, from, size);
 
-       if (unlikely(ret))
-               ret = copy_to_user_fixup(to, from, size);
+       if (unlikely(ret)) {
+               if ((long)ret < 0)
+                       ret = copy_to_user_fixup(to, from, size);
+               return ret;
+       }
        return ret;
 }
 #define __copy_to_user copy_to_user
@@ -244,8 +250,11 @@ copy_in_user(void __user *to, void __user *from, unsigned long size)
 {
        unsigned long ret = ___copy_in_user(to, from, size);
 
-       if (unlikely(ret))
-               ret = copy_in_user_fixup(to, from, size);
+       if (unlikely(ret)) {
+               if ((long)ret < 0)
+                       ret = copy_in_user_fixup(to, from, size);
+               return ret;
+       }
        return ret;
 }
 #define __copy_in_user copy_in_user