diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-04-09 11:15:02 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-04-09 11:15:02 -0600 |
commit | 1f65f52d131ad92fda8a025f7d670e7a1a42a187 (patch) | |
tree | 94db6a91932dfb958afa95fe597e9df02b87a2f1 | |
parent | fec50db7033ea478773b159e0e2efb135270e3b7 (diff) | |
parent | e82051193a171f393d2a165a7ce18d8a2e2b4837 (diff) |
Merge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs into read_iter
* 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
new helper: copy_to_iter_full()
-rw-r--r-- | include/linux/uio.h | 10 | ||||
-rw-r--r-- | include/net/udp.h | 9 |
2 files changed, 11 insertions, 8 deletions
diff --git a/include/linux/uio.h b/include/linux/uio.h index 00cebe2b70de..7020adedfa08 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -206,6 +206,16 @@ size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i) } static __always_inline __must_check +bool copy_to_iter_full(const void *addr, size_t bytes, struct iov_iter *i) +{ + size_t copied = copy_to_iter(addr, bytes, i); + if (likely(copied == bytes)) + return true; + iov_iter_revert(i, copied); + return false; +} + +static __always_inline __must_check bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i) { size_t copied = copy_from_iter(addr, bytes, i); diff --git a/include/net/udp.h b/include/net/udp.h index 488a6d2babcc..c4e05b14b648 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -379,14 +379,7 @@ static inline bool udp_skb_is_linear(struct sk_buff *skb) static inline int copy_linear_skb(struct sk_buff *skb, int len, int off, struct iov_iter *to) { - int n; - - n = copy_to_iter(skb->data + off, len, to); - if (n == len) - return 0; - - iov_iter_revert(to, n); - return -EFAULT; + return copy_to_iter_full(skb->data + off, len, to) ? 0 : -EFAULT; } /* |