Commit 0e3c3b90 authored by Al Viro's avatar Al Viro

No need of likely/unlikely on calls of check_copy_size()

it's inline and unlikely() inside of it (including the implicit one
in WARN_ON_ONCE()) suffice to convince the compiler that getting
false from check_copy_size() is unlikely.
Spotted-by: default avatarJens Axboe <axboe@kernel.dk>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f2906aa8
...@@ -348,7 +348,7 @@ copy_mc_to_kernel(void *to, const void *from, unsigned long size) ...@@ -348,7 +348,7 @@ copy_mc_to_kernel(void *to, const void *from, unsigned long size)
static inline unsigned long __must_check static inline unsigned long __must_check
copy_mc_to_user(void __user *to, const void *from, unsigned long n) copy_mc_to_user(void __user *to, const void *from, unsigned long n)
{ {
if (likely(check_copy_size(from, n, true))) { if (check_copy_size(from, n, true)) {
if (access_ok(to, n)) { if (access_ok(to, n)) {
allow_write_to_user(to, n); allow_write_to_user(to, n);
n = copy_mc_generic((void *)to, from, n); n = copy_mc_generic((void *)to, from, n);
......
...@@ -39,7 +39,7 @@ _copy_from_user_key(void *to, const void __user *from, unsigned long n, unsigned ...@@ -39,7 +39,7 @@ _copy_from_user_key(void *to, const void __user *from, unsigned long n, unsigned
static __always_inline unsigned long __must_check static __always_inline unsigned long __must_check
copy_from_user_key(void *to, const void __user *from, unsigned long n, unsigned long key) copy_from_user_key(void *to, const void __user *from, unsigned long n, unsigned long key)
{ {
if (likely(check_copy_size(to, n, false))) if (check_copy_size(to, n, false))
n = _copy_from_user_key(to, from, n, key); n = _copy_from_user_key(to, from, n, key);
return n; return n;
} }
...@@ -50,7 +50,7 @@ _copy_to_user_key(void __user *to, const void *from, unsigned long n, unsigned l ...@@ -50,7 +50,7 @@ _copy_to_user_key(void __user *to, const void *from, unsigned long n, unsigned l
static __always_inline unsigned long __must_check static __always_inline unsigned long __must_check
copy_to_user_key(void __user *to, const void *from, unsigned long n, unsigned long key) copy_to_user_key(void __user *to, const void *from, unsigned long n, unsigned long key)
{ {
if (likely(check_copy_size(from, n, true))) if (check_copy_size(from, n, true))
n = _copy_to_user_key(to, from, n, key); n = _copy_to_user_key(to, from, n, key);
return n; return n;
} }
......
...@@ -148,7 +148,7 @@ _copy_to_user(void __user *, const void *, unsigned long); ...@@ -148,7 +148,7 @@ _copy_to_user(void __user *, const void *, unsigned long);
static __always_inline unsigned long __must_check static __always_inline unsigned long __must_check
copy_from_user(void *to, const void __user *from, unsigned long n) copy_from_user(void *to, const void __user *from, unsigned long n)
{ {
if (likely(check_copy_size(to, n, false))) if (check_copy_size(to, n, false))
n = _copy_from_user(to, from, n); n = _copy_from_user(to, from, n);
return n; return n;
} }
...@@ -156,7 +156,7 @@ copy_from_user(void *to, const void __user *from, unsigned long n) ...@@ -156,7 +156,7 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
static __always_inline unsigned long __must_check static __always_inline unsigned long __must_check
copy_to_user(void __user *to, const void *from, unsigned long n) copy_to_user(void __user *to, const void *from, unsigned long n)
{ {
if (likely(check_copy_size(from, n, true))) if (check_copy_size(from, n, true))
n = _copy_to_user(to, from, n); n = _copy_to_user(to, from, n);
return n; return n;
} }
......
...@@ -156,19 +156,17 @@ static inline size_t copy_folio_to_iter(struct folio *folio, size_t offset, ...@@ -156,19 +156,17 @@ static inline size_t copy_folio_to_iter(struct folio *folio, size_t offset,
static __always_inline __must_check static __always_inline __must_check
size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i) size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)
{ {
if (unlikely(!check_copy_size(addr, bytes, true))) if (check_copy_size(addr, bytes, true))
return 0;
else
return _copy_to_iter(addr, bytes, i); return _copy_to_iter(addr, bytes, i);
return 0;
} }
static __always_inline __must_check static __always_inline __must_check
size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i) size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i)
{ {
if (unlikely(!check_copy_size(addr, bytes, false))) if (check_copy_size(addr, bytes, false))
return 0;
else
return _copy_from_iter(addr, bytes, i); return _copy_from_iter(addr, bytes, i);
return 0;
} }
static __always_inline __must_check static __always_inline __must_check
...@@ -184,10 +182,9 @@ bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i) ...@@ -184,10 +182,9 @@ bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
static __always_inline __must_check static __always_inline __must_check
size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i) size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i)
{ {
if (unlikely(!check_copy_size(addr, bytes, false))) if (check_copy_size(addr, bytes, false))
return 0;
else
return _copy_from_iter_nocache(addr, bytes, i); return _copy_from_iter_nocache(addr, bytes, i);
return 0;
} }
static __always_inline __must_check static __always_inline __must_check
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment