summaryrefslogtreecommitdiff
path: root/arch/x86/lib/usercopy.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/lib/usercopy.c')
-rw-r--r--arch/x86/lib/usercopy.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c
index c074799bddae..a851f3d199c2 100644
--- a/arch/x86/lib/usercopy.c
+++ b/arch/x86/lib/usercopy.c
@@ -76,10 +76,11 @@ EXPORT_SYMBOL(_copy_to_user);
*/
unsigned long _copy_from_user(void *to, const void __user *from, unsigned n)
{
+ unsigned long res = n;
if (access_ok(VERIFY_READ, from, n))
- n = __copy_from_user(to, from, n);
- else
- memset(to, 0, n);
- return n;
+ res = __copy_from_user_inatomic(to, from, n);
+ if (unlikely(res))
+ memset(to + n - res, 0, res);
+ return res;
}
EXPORT_SYMBOL(_copy_from_user);