[PATCH] vhost: fix return value of vhost_get_vq_desc

From: Eugenio PÃrez
Date: Tue Feb 11 2020 - 07:19:10 EST


Before of the batch change, it was the chain's head. Need to keep that
way or we will not be able to free a chain of descriptors.

Fixes: eccb852f1fe6 ("vhost: batching fetches")
---
drivers/vhost/vhost.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index b5a51b1f2e79..fc422c3e5c08 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -2409,12 +2409,11 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
*out_num += ret;
}

- ret = desc->id;
-
if (!(desc->flags & VRING_DESC_F_NEXT))
break;
}

+ ret = vq->descs[vq->first_desc].id;
vq->first_desc = i + 1;

return ret;
--
2.18.1