summaryrefslogtreecommitdiffstats
path: root/include/asm-generic/uaccess.h
diff options
context:
space:
mode:
authorYoshinori Sato <ysato@users.sourceforge.jp>2015-07-16 00:56:06 -0400
committerYoshinori Sato <ysato@users.sourceforge.jp>2015-11-08 08:44:42 -0500
commita02613a4ba679eacec8251976d02809d533fa717 (patch)
tree90d5aabd15bee0954437bcf96b4c13e0901e63e7 /include/asm-generic/uaccess.h
parenta795239b698d3f7c455b7f8841f5c62d20eefb23 (diff)
asm-generic: {get,put}_user ptr argument evaluate only 1 time
Current implemantation ptr argument evaluate 2 times. It'll be an unexpected result. Changes v5: Remove unnecessary const. Changes v4: Temporary pointer type change to const void* Changes v3: Some build error fix. Changes v2: Argument x protect. Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Diffstat (limited to 'include/asm-generic/uaccess.h')
-rw-r--r--include/asm-generic/uaccess.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 72d8803832ff..1bfa602958f2 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -163,9 +163,10 @@ static inline __must_check long __copy_to_user(void __user *to,
163 163
164#define put_user(x, ptr) \ 164#define put_user(x, ptr) \
165({ \ 165({ \
166 void *__p = (ptr); \
166 might_fault(); \ 167 might_fault(); \
167 access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \ 168 access_ok(VERIFY_WRITE, __p, sizeof(*ptr)) ? \
168 __put_user(x, ptr) : \ 169 __put_user((x), ((__typeof__(*(ptr)) *)__p)) : \
169 -EFAULT; \ 170 -EFAULT; \
170}) 171})
171 172
@@ -225,9 +226,10 @@ extern int __put_user_bad(void) __attribute__((noreturn));
225 226
226#define get_user(x, ptr) \ 227#define get_user(x, ptr) \
227({ \ 228({ \
229 const void *__p = (ptr); \
228 might_fault(); \ 230 might_fault(); \
229 access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \ 231 access_ok(VERIFY_READ, __p, sizeof(*ptr)) ? \
230 __get_user(x, ptr) : \ 232 __get_user((x), (__typeof__(*(ptr)) *)__p) : \
231 -EFAULT; \ 233 -EFAULT; \
232}) 234})
233 235