diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-09-09 19:22:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-09-24 10:09:38 +0200 |
commit | 970509fa0ba67f00b984b54d15d35d25824fe912 (patch) | |
tree | 6d06f8ed40ea29bd6d613fd3c0a95283f3fe8343 | |
parent | d4b8c2e5a2a5b0d9cf6cbd45c380641ee784b011 (diff) | |
download | lwn-970509fa0ba67f00b984b54d15d35d25824fe912.tar.gz lwn-970509fa0ba67f00b984b54d15d35d25824fe912.zip |
microblaze: fix copy_from_user()
commit d0cf385160c12abd109746cad1f13e3b3e8b50b8 upstream.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | arch/microblaze/include/asm/uaccess.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h index 905a9c67f6b8..826676778094 100644 --- a/arch/microblaze/include/asm/uaccess.h +++ b/arch/microblaze/include/asm/uaccess.h @@ -373,10 +373,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_fault(); - 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) \ |