Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vringh: don't use vringh_kiov_advance() in vringh_iov_xfer()

In the while loop of vringh_iov_xfer(), `partlen` could be 0 if one of
the `iov` has 0 lenght.
In this case, we should skip the iov and go to the next one.
But calling vringh_kiov_advance() with 0 lenght does not cause the
advancement, since it returns immediately if asked to advance by 0 bytes.

Let's restore the code that was there before commit b8c06ad4d67d
("vringh: implement vringh_kiov_advance()"), avoiding using
vringh_kiov_advance().

Fixes: b8c06ad4d67d ("vringh: implement vringh_kiov_advance()")
Cc: stable@vger.kernel.org
Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Stefano Garzarella and committed by
David S. Miller
7aed44ba a0c55bba

+11 -1
+11 -1
drivers/vhost/vringh.c
··· 123 123 done += partlen; 124 124 len -= partlen; 125 125 ptr += partlen; 126 + iov->consumed += partlen; 127 + iov->iov[iov->i].iov_len -= partlen; 128 + iov->iov[iov->i].iov_base += partlen; 126 129 127 - vringh_kiov_advance(iov, partlen); 130 + if (!iov->iov[iov->i].iov_len) { 131 + /* Fix up old iov element then increment. */ 132 + iov->iov[iov->i].iov_len = iov->consumed; 133 + iov->iov[iov->i].iov_base -= iov->consumed; 134 + 135 + iov->consumed = 0; 136 + iov->i++; 137 + } 128 138 } 129 139 return done; 130 140 }