summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-09-09 19:22:34 -0400
committerBen Hutchings <ben@decadent.org.uk>2016-11-20 01:01:40 +0000
commitf5f944fb34661325716158eaafcd518e16a1f7cc (patch)
tree4b957aee6a9ca7615453f60b6d088945f0084992
parentf69350b23246c539a012f58b5f8242cb18a4a813 (diff)
downloadlwn-f5f944fb34661325716158eaafcd518e16a1f7cc.tar.gz
lwn-f5f944fb34661325716158eaafcd518e16a1f7cc.zip
microblaze: fix copy_from_user()
commit d0cf385160c12abd109746cad1f13e3b3e8b50b8 upstream. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--arch/microblaze/include/asm/uaccess.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index 072b0077abf9..36ea6fe84990 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -364,10 +364,13 @@ extern long __user_bad(void);
static inline long copy_from_user(void *to,
const void __user *from, unsigned long n)
{
+ unsigned long res = n;
might_sleep();
- if (access_ok(VERIFY_READ, from, n))
- return __copy_from_user(to, from, n);
- return n;
+ if (likely(access_ok(VERIFY_READ, from, n)))
+ res = __copy_from_user(to, from, n);
+ if (unlikely(res))
+ memset(to + (n - res), 0, res);
+ return res;
}
#define __copy_to_user(to, from, n) \