Skip to content

Commit 07f2402

Browse files
jniaxLinus Torvalds
authored andcommitted
cris: correct usage of __user for copy to and from user space in lib/usercopy and uaccess.h
Function __copy_user_zeroing in arch/lib/usercopy.c had the wrong parameter set as __user, and in include/asm-cris/uaccess.h, it was not set at all for some of the calling functions. This will cut the number of warnings quite dramatically when using sparse. While we're here, remove useless CVS log and correct confusing typo. Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com> Cc: Mikael Starvik <mikael.starvik@axis.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cee47f5 commit 07f2402

3 files changed

Lines changed: 11 additions & 46 deletions

File tree

‎arch/cris/arch-v10/lib/usercopy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ __copy_user (void __user *pdst, const void *psrc, unsigned long pn)
193193
inaccessible. */
194194

195195
unsigned long
196-
__copy_user_zeroing (void __user *pdst, const void *psrc, unsigned long pn)
196+
__copy_user_zeroing(void *pdst, const void __user *psrc, unsigned long pn)
197197
{
198198
/* We want the parameters put in special registers.
199199
Make sure the compiler is able to make something useful of this.

‎arch/cris/arch-v32/lib/usercopy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ __copy_user (void __user *pdst, const void *psrc, unsigned long pn)
161161
inaccessible. */
162162

163163
unsigned long
164-
__copy_user_zeroing (void __user *pdst, const void *psrc, unsigned long pn)
164+
__copy_user_zeroing(void *pdst, const void __user *psrc, unsigned long pn)
165165
{
166166
/* We want the parameters put in special registers.
167167
Make sure the compiler is able to make something useful of this.

‎include/asm-cris/uaccess.h‎

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,6 @@
11
/*
22
* Authors: Bjorn Wesen (bjornw@axis.com)
33
* Hans-Peter Nilsson (hp@axis.com)
4-
*
5-
* $Log: uaccess.h,v $
6-
* Revision 1.8 2001/10/29 13:01:48 bjornw
7-
* Removed unused variable tmp2 in strnlen_user
8-
*
9-
* Revision 1.7 2001/10/02 12:44:52 hp
10-
* Add support for 64-bit put_user/get_user
11-
*
12-
* Revision 1.6 2001/10/01 14:51:17 bjornw
13-
* Added register prefixes and removed underscores
14-
*
15-
* Revision 1.5 2000/10/25 03:33:21 hp
16-
* - Provide implementation for everything else but get_user and put_user;
17-
* copying inline to/from user for constant length 0..16, 20, 24, and
18-
* clearing for 0..4, 8, 12, 16, 20, 24, strncpy_from_user and strnlen_user
19-
* always inline.
20-
* - Constraints for destination addr in get_user cannot be memory, only reg.
21-
* - Correct labels for PC at expected fault points.
22-
* - Nits with assembly code.
23-
* - Don't use statement expressions without value; use "do {} while (0)".
24-
* - Return correct values from __generic_... functions.
25-
*
26-
* Revision 1.4 2000/09/12 16:28:25 bjornw
27-
* * Removed comments from the get/put user asm code
28-
* * Constrains for destination addr in put_user cannot be memory, only reg
29-
*
30-
* Revision 1.3 2000/09/12 14:30:20 bjornw
31-
* MAX_ADDR_USER does not exist anymore
32-
*
33-
* Revision 1.2 2000/07/13 15:52:48 bjornw
34-
* New user-access functions
35-
*
36-
* Revision 1.1.1.1 2000/07/10 16:32:31 bjornw
37-
* CRIS architecture, working draft
38-
*
39-
*
40-
*
414
*/
425

436
/* Asm:s have been tweaked (within the domain of correctness) to give
@@ -209,9 +172,9 @@ extern long __get_user_bad(void);
209172
/* More complex functions. Most are inline, but some call functions that
210173
live in lib/usercopy.c */
211174

212-
extern unsigned long __copy_user(void *to, const void *from, unsigned long n);
213-
extern unsigned long __copy_user_zeroing(void *to, const void *from, unsigned long n);
214-
extern unsigned long __do_clear_user(void *to, unsigned long n);
175+
extern unsigned long __copy_user(void __user *to, const void *from, unsigned long n);
176+
extern unsigned long __copy_user_zeroing(void *to, const void __user *from, unsigned long n);
177+
extern unsigned long __do_clear_user(void __user *to, unsigned long n);
215178

216179
static inline unsigned long
217180
__generic_copy_to_user(void __user *to, const void *from, unsigned long n)
@@ -253,7 +216,7 @@ strncpy_from_user(char *dst, const char __user *src, long count)
253216
}
254217

255218

256-
/* Note that if these expand awfully if made into switch constructs, so
219+
/* Note that these expand awfully if made into switch constructs, so
257220
don't do that. */
258221

259222
static inline unsigned long
@@ -407,19 +370,21 @@ __constant_clear_user(void __user *to, unsigned long n)
407370
*/
408371

409372
static inline unsigned long
410-
__generic_copy_from_user_nocheck(void *to, const void *from, unsigned long n)
373+
__generic_copy_from_user_nocheck(void *to, const void __user *from,
374+
unsigned long n)
411375
{
412376
return __copy_user_zeroing(to,from,n);
413377
}
414378

415379
static inline unsigned long
416-
__generic_copy_to_user_nocheck(void *to, const void *from, unsigned long n)
380+
__generic_copy_to_user_nocheck(void __user *to, const void *from,
381+
unsigned long n)
417382
{
418383
return __copy_user(to,from,n);
419384
}
420385

421386
static inline unsigned long
422-
__generic_clear_user_nocheck(void *to, unsigned long n)
387+
__generic_clear_user_nocheck(void __user *to, unsigned long n)
423388
{
424389
return __do_clear_user(to,n);
425390
}

0 commit comments

Comments
 (0)