summaryrefslogtreecommitdiff
path: root/arch/x86/lib/usercopy.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-03-25 18:36:22 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-03-28 18:24:04 -0400
commit122b05ddf506e637336dcf64b5a129825f7bf6d4 (patch)
treee8addfa4b5747e198698c0d54789b077cf2a92a0 /arch/x86/lib/usercopy.c
parentd597580d373774b1bdab84b3d26ff0b55162b916 (diff)
amd64: get rid of zeroing
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
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);