diff --git a/net/core/datagram.c b/net/core/datagram.c index c285c6465923..da10465cd8a4 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -748,10 +748,13 @@ int __zerocopy_sg_from_iter(struct msghdr *msg, struct sock *sk, size_t length, struct net_devmem_dmabuf_binding *binding) { + struct iov_iter_state state; unsigned long orig_size = skb->truesize; unsigned long truesize; int ret; + iov_iter_save_state(from, &state); + if (msg && msg->msg_ubuf && msg->sg_from_iter) ret = msg->sg_from_iter(skb, from, length); else if (binding) @@ -759,6 +762,9 @@ int __zerocopy_sg_from_iter(struct msghdr *msg, struct sock *sk, else ret = zerocopy_fill_skb_from_iter(skb, from, length); + if (ret) + iov_iter_restore(from, &state); + truesize = skb->truesize - orig_size; if (sk && sk->sk_type == SOCK_STREAM) { sk_wmem_queued_add(sk, truesize);