Commit 13e4cdd7 authored by Julien Thierry's avatar Julien Thierry Committed by Catalin Marinas

arm64: uaccess: Cleanup get/put_user()

__get/put_user_check() macro is made to return a value but this is never
used. Get rid of them and just use directly __get/put_user_error() as
a statement, reducing macro indirection.

Also, take this opportunity to rename __get/put_user_err() as it gets
a bit confusing having them along __get/put_user_error().
Signed-off-by: default avatarJulien Thierry <julien.thierry@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 5b498e13
......@@ -268,7 +268,7 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr)
: "+r" (err), "=&r" (x) \
: "r" (addr), "i" (-EFAULT))
#define __get_user_err(x, ptr, err) \
#define __raw_get_user(x, ptr, err) \
do { \
unsigned long __gu_val; \
__chk_user_ptr(ptr); \
......@@ -297,28 +297,22 @@ do { \
(x) = (__force __typeof__(*(ptr)))__gu_val; \
} while (0)
#define __get_user_check(x, ptr, err) \
({ \
#define __get_user_error(x, ptr, err) \
do { \
__typeof__(*(ptr)) __user *__p = (ptr); \
might_fault(); \
if (access_ok(__p, sizeof(*__p))) { \
__p = uaccess_mask_ptr(__p); \
__get_user_err((x), __p, (err)); \
__raw_get_user((x), __p, (err)); \
} else { \
(x) = 0; (err) = -EFAULT; \
} \
})
#define __get_user_error(x, ptr, err) \
({ \
__get_user_check((x), (ptr), (err)); \
(void)0; \
})
} while (0)
#define __get_user(x, ptr) \
({ \
int __gu_err = 0; \
__get_user_check((x), (ptr), __gu_err); \
__get_user_error((x), (ptr), __gu_err); \
__gu_err; \
})
......@@ -338,7 +332,7 @@ do { \
: "+r" (err) \
: "r" (x), "r" (addr), "i" (-EFAULT))
#define __put_user_err(x, ptr, err) \
#define __raw_put_user(x, ptr, err) \
do { \
__typeof__(*(ptr)) __pu_val = (x); \
__chk_user_ptr(ptr); \
......@@ -366,28 +360,22 @@ do { \
uaccess_disable_not_uao(); \
} while (0)
#define __put_user_check(x, ptr, err) \
({ \
#define __put_user_error(x, ptr, err) \
do { \
__typeof__(*(ptr)) __user *__p = (ptr); \
might_fault(); \
if (access_ok(__p, sizeof(*__p))) { \
__p = uaccess_mask_ptr(__p); \
__put_user_err((x), __p, (err)); \
__raw_put_user((x), __p, (err)); \
} else { \
(err) = -EFAULT; \
} \
})
#define __put_user_error(x, ptr, err) \
({ \
__put_user_check((x), (ptr), (err)); \
(void)0; \
})
} while (0)
#define __put_user(x, ptr) \
({ \
int __pu_err = 0; \
__put_user_check((x), (ptr), __pu_err); \
__put_user_error((x), (ptr), __pu_err); \
__pu_err; \
})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment