mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-24 05:01:03 +02:00
uaccess: add generic __{get,put}_kernel_nofault
Nine architectures are still missing __{get,put}_kernel_nofault: alpha, ia64, microblaze, nds32, nios2, openrisc, sh, sparc32, xtensa. Add a generic version that lets everything use the normal copy_{from,to}_kernel_nofault() code based on these, removing the last use of get_fs()/set_fs() from architecture-independent code. Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -368,6 +368,25 @@ long strncpy_from_user_nofault(char *dst, const void __user *unsafe_addr,
|
||||
long count);
|
||||
long strnlen_user_nofault(const void __user *unsafe_addr, long count);
|
||||
|
||||
#ifndef __get_kernel_nofault
|
||||
#define __get_kernel_nofault(dst, src, type, label) \
|
||||
do { \
|
||||
type __user *p = (type __force __user *)(src); \
|
||||
type data; \
|
||||
if (__get_user(data, p)) \
|
||||
goto label; \
|
||||
*(type *)dst = data; \
|
||||
} while (0)
|
||||
|
||||
#define __put_kernel_nofault(dst, src, type, label) \
|
||||
do { \
|
||||
type __user *p = (type __force __user *)(dst); \
|
||||
type data = *(type *)src; \
|
||||
if (__put_user(data, p)) \
|
||||
goto label; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* get_kernel_nofault(): safely attempt to read from a location
|
||||
* @val: read into this variable
|
||||
|
Reference in New Issue
Block a user