Skip to content

Commit 9afcc71

Browse files
committed
xtensa: fix error paths in __get_user_{check,size}
Error paths in __get_user_check and __get_user_size directly assing 0 to the result. It causes the following sparse warnings: sparse: warning: Using plain integer as NULL pointer Convert 0 to the type pointed to by the user pointer before assigning it. Signed-off-by: Max Filippov <[email protected]>
1 parent c22f907 commit 9afcc71

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/xtensa/include/asm/uaccess.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ __asm__ __volatile__( \
184184
if (access_ok(__gu_addr, size)) \
185185
__get_user_size((x), __gu_addr, (size), __gu_err); \
186186
else \
187-
(x) = 0; \
187+
(x) = (__typeof__(*(ptr)))0; \
188188
__gu_err; \
189189
})
190190

@@ -202,13 +202,15 @@ do { \
202202
u64 __x; \
203203
if (unlikely(__copy_from_user(&__x, ptr, 8))) { \
204204
retval = -EFAULT; \
205-
(x) = 0; \
205+
(x) = (__typeof__(*(ptr)))0; \
206206
} else { \
207207
(x) = *(__force __typeof__(*(ptr)) *)&__x; \
208208
} \
209209
break; \
210210
} \
211-
default: (x) = 0; __get_user_bad(); \
211+
default: \
212+
(x) = (__typeof__(*(ptr)))0; \
213+
__get_user_bad(); \
212214
} \
213215
} while (0)
214216

0 commit comments

Comments
 (0)