vringh: reset kiov 'consumed' field in __vringh_iov()
authorStefano Garzarella <sgarzare@redhat.com>
Mon, 15 Mar 2021 16:34:39 +0000 (17:34 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 3 May 2021 08:55:53 +0000 (04:55 -0400)
__vringh_iov() overwrites the contents of riov and wiov, in fact it
resets the 'i' and 'used' fields, but also the 'consumed' field should
be reset to avoid an inconsistent state.

Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210315163450.254396-4-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vringh.c

index f681227..bee63d6 100644 (file)
@@ -290,9 +290,9 @@ __vringh_iov(struct vringh *vrh, u16 i,
                return -EINVAL;
 
        if (riov)
-               riov->i = riov->used = 0;
+               riov->i = riov->used = riov->consumed = 0;
        if (wiov)
-               wiov->i = wiov->used = 0;
+               wiov->i = wiov->used = wiov->consumed = 0;
 
        for (;;) {
                void *addr;