Skip to content

Commit 1f65f52

Browse files
committed
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()
2 parents fec50db + e820511 commit 1f65f52

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

include/linux/uio.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i)
205205
return 0;
206206
}
207207

208+
static __always_inline __must_check
209+
bool copy_to_iter_full(const void *addr, size_t bytes, struct iov_iter *i)
210+
{
211+
size_t copied = copy_to_iter(addr, bytes, i);
212+
if (likely(copied == bytes))
213+
return true;
214+
iov_iter_revert(i, copied);
215+
return false;
216+
}
217+
208218
static __always_inline __must_check
209219
bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
210220
{

include/net/udp.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,7 @@ static inline bool udp_skb_is_linear(struct sk_buff *skb)
379379
static inline int copy_linear_skb(struct sk_buff *skb, int len, int off,
380380
struct iov_iter *to)
381381
{
382-
int n;
383-
384-
n = copy_to_iter(skb->data + off, len, to);
385-
if (n == len)
386-
return 0;
387-
388-
iov_iter_revert(to, n);
389-
return -EFAULT;
382+
return copy_to_iter_full(skb->data + off, len, to) ? 0 : -EFAULT;
390383
}
391384

392385
/*

0 commit comments

Comments
 (0)