diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2015-01-06 07:37:22 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-01-13 08:23:36 -0500 |
commit | 9ef8dc161faaa24c58322aa928b3216213621daa (patch) | |
tree | 81d63064c315af3aaa2deec13bfcdd0744d63eb2 | |
parent | 9605ce7e5fe058c94fa354415d122462fb419a00 (diff) |
metag: fix put_user sparse errors
virtio wants to write bitwise types to userspace using put_user.
At the moment this triggers sparse errors, since the value is passed
through an integer.
For example:
__le32 __user *p;
__le32 x;
put_user(x, p);
is safe, but currently triggers a sparse warning.
Fix that up using __force.
This also fixes warnings due to writing a pointer out to
userland.
Note: this does not suppress any useful sparse checks since callers
do a cast (__typeof__(*(ptr))) (x) which in turn forces all the
necessary type checks.
Suggested-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: James Hogan <james.hogan@imgtec.com>
-rw-r--r-- | arch/metag/include/asm/uaccess.h | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h index fd863fead4af..8282cbce7e39 100644 --- a/arch/metag/include/asm/uaccess.h +++ b/arch/metag/include/asm/uaccess.h | |||
@@ -107,18 +107,23 @@ extern long __put_user_asm_w(unsigned int x, void __user *addr); | |||
107 | extern long __put_user_asm_d(unsigned int x, void __user *addr); | 107 | extern long __put_user_asm_d(unsigned int x, void __user *addr); |
108 | extern long __put_user_asm_l(unsigned long long x, void __user *addr); | 108 | extern long __put_user_asm_l(unsigned long long x, void __user *addr); |
109 | 109 | ||
110 | #define __put_user_size(x, ptr, size, retval) \ | 110 | #define __put_user_size(x, ptr, size, retval) \ |
111 | do { \ | 111 | do { \ |
112 | retval = 0; \ | 112 | retval = 0; \ |
113 | switch (size) { \ | 113 | switch (size) { \ |
114 | case 1: \ | 114 | case 1: \ |
115 | retval = __put_user_asm_b((unsigned int)x, ptr); break; \ | 115 | retval = __put_user_asm_b((__force unsigned int)x, ptr);\ |
116 | break; \ | ||
116 | case 2: \ | 117 | case 2: \ |
117 | retval = __put_user_asm_w((unsigned int)x, ptr); break; \ | 118 | retval = __put_user_asm_w((__force unsigned int)x, ptr);\ |
119 | break; \ | ||
118 | case 4: \ | 120 | case 4: \ |
119 | retval = __put_user_asm_d((unsigned int)x, ptr); break; \ | 121 | retval = __put_user_asm_d((__force unsigned int)x, ptr);\ |
122 | break; \ | ||
120 | case 8: \ | 123 | case 8: \ |
121 | retval = __put_user_asm_l((unsigned long long)x, ptr); break; \ | 124 | retval = __put_user_asm_l((__force unsigned long long)x,\ |
125 | ptr); \ | ||
126 | break; \ | ||
122 | default: \ | 127 | default: \ |
123 | __put_user_bad(); \ | 128 | __put_user_bad(); \ |
124 | } \ | 129 | } \ |