diff options
author | Chris Metcalf <cmetcalf@ezchip.com> | 2015-01-13 14:41:20 -0500 |
---|---|---|
committer | Chris Metcalf <cmetcalf@ezchip.com> | 2015-01-13 18:44:34 -0500 |
commit | b9f705758a4faaf86532bddf6ea3c50d6778ba42 (patch) | |
tree | 83933b15cb7715a61cfd6635a1b5221ebdf818bf /arch/tile | |
parent | f3c927125fa49a42d596434d1ed454195c0d4530 (diff) |
tile: enable sparse checks for get/put_user
Add an extra intermediate variable to __get_user and __put_user
to give sparse an opportunity to detect mismatches.
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
Diffstat (limited to 'arch/tile')
-rw-r--r-- | arch/tile/include/asm/uaccess.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h index b81b24a8489b..f41cb53cf645 100644 --- a/arch/tile/include/asm/uaccess.h +++ b/arch/tile/include/asm/uaccess.h | |||
@@ -210,14 +210,16 @@ extern int __get_user_bad(void) | |||
210 | #define __get_user(x, ptr) \ | 210 | #define __get_user(x, ptr) \ |
211 | ({ \ | 211 | ({ \ |
212 | int __ret; \ | 212 | int __ret; \ |
213 | typeof(x) _x; \ | ||
213 | __chk_user_ptr(ptr); \ | 214 | __chk_user_ptr(ptr); \ |
214 | switch (sizeof(*(ptr))) { \ | 215 | switch (sizeof(*(ptr))) { \ |
215 | case 1: __get_user_1(x, ptr, __ret); break; \ | 216 | case 1: __get_user_1(_x, ptr, __ret); break; \ |
216 | case 2: __get_user_2(x, ptr, __ret); break; \ | 217 | case 2: __get_user_2(_x, ptr, __ret); break; \ |
217 | case 4: __get_user_4(x, ptr, __ret); break; \ | 218 | case 4: __get_user_4(_x, ptr, __ret); break; \ |
218 | case 8: __get_user_8(x, ptr, __ret); break; \ | 219 | case 8: __get_user_8(_x, ptr, __ret); break; \ |
219 | default: __ret = __get_user_bad(); break; \ | 220 | default: __ret = __get_user_bad(); break; \ |
220 | } \ | 221 | } \ |
222 | (x) = (typeof(*(ptr))) _x; \ | ||
221 | __ret; \ | 223 | __ret; \ |
222 | }) | 224 | }) |
223 | 225 | ||
@@ -289,12 +291,13 @@ extern int __put_user_bad(void) | |||
289 | #define __put_user(x, ptr) \ | 291 | #define __put_user(x, ptr) \ |
290 | ({ \ | 292 | ({ \ |
291 | int __ret; \ | 293 | int __ret; \ |
294 | typeof(*(ptr)) _x = (x); \ | ||
292 | __chk_user_ptr(ptr); \ | 295 | __chk_user_ptr(ptr); \ |
293 | switch (sizeof(*(ptr))) { \ | 296 | switch (sizeof(*(ptr))) { \ |
294 | case 1: __put_user_1(x, ptr, __ret); break; \ | 297 | case 1: __put_user_1(_x, ptr, __ret); break; \ |
295 | case 2: __put_user_2(x, ptr, __ret); break; \ | 298 | case 2: __put_user_2(_x, ptr, __ret); break; \ |
296 | case 4: __put_user_4(x, ptr, __ret); break; \ | 299 | case 4: __put_user_4(_x, ptr, __ret); break; \ |
297 | case 8: __put_user_8(x, ptr, __ret); break; \ | 300 | case 8: __put_user_8(_x, ptr, __ret); break; \ |
298 | default: __ret = __put_user_bad(); break; \ | 301 | default: __ret = __put_user_bad(); break; \ |
299 | } \ | 302 | } \ |
300 | __ret; \ | 303 | __ret; \ |