sfp: improve RX_LOS handling
[linux-2.6/btrfs-unstable.git] / lib / usercopy.c
blob15e2e6fb060ef20b35ba8e93f6de932d7db5a0df
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/uaccess.h>
4 /* out-of-line parts */
6 #ifndef INLINE_COPY_FROM_USER
7 unsigned long _copy_from_user(void *to, const void __user *from, unsigned long n)
9 unsigned long res = n;
10 might_fault();
11 if (likely(access_ok(VERIFY_READ, from, n))) {
12 kasan_check_write(to, n);
13 res = raw_copy_from_user(to, from, n);
15 if (unlikely(res))
16 memset(to + (n - res), 0, res);
17 return res;
19 EXPORT_SYMBOL(_copy_from_user);
20 #endif
22 #ifndef INLINE_COPY_TO_USER
23 unsigned long _copy_to_user(void *to, const void __user *from, unsigned long n)
25 might_fault();
26 if (likely(access_ok(VERIFY_WRITE, to, n))) {
27 kasan_check_read(from, n);
28 n = raw_copy_to_user(to, from, n);
30 return n;
32 EXPORT_SYMBOL(_copy_to_user);
33 #endif