vhost: fix desc access in relay helpers
authorTiwei Bie <tiwei.bie@intel.com>
Fri, 4 Jan 2019 04:06:37 +0000 (12:06 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 Jan 2019 16:44:29 +0000 (17:44 +0100)
Descs in desc table should be indexed using the desc idx
instead of the idx of avail ring and used ring.

Fixes: b13ad2decc83 ("vhost: provide helpers for virtio ring relay")

Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/vdpa.c

index 240a1fe..77d92f9 100644 (file)
@@ -190,10 +190,10 @@ rte_vdpa_relay_vring_avail(int vid, uint16_t qid, void *vring_m)
                        if (unlikely(!desc_ring))
                                return -1;
 
-                       if (unlikely(dlen < vq->desc[idx].len)) {
+                       if (unlikely(dlen < vq->desc[desc_id].len)) {
                                idesc = alloc_copy_ind_table(dev, vq,
-                                               vq->desc[idx].addr,
-                                               vq->desc[idx].len);
+                                               vq->desc[desc_id].addr,
+                                               vq->desc[desc_id].len);
                                if (unlikely(!idesc))
                                        return -1;
 
@@ -279,10 +279,10 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
                        if (unlikely(!desc_ring))
                                return -1;
 
-                       if (unlikely(dlen < vq->desc[idx].len)) {
+                       if (unlikely(dlen < vq->desc[desc_id].len)) {
                                idesc = alloc_copy_ind_table(dev, vq,
-                                               vq->desc[idx].addr,
-                                               vq->desc[idx].len);
+                                               vq->desc[desc_id].addr,
+                                               vq->desc[desc_id].len);
                                if (unlikely(!idesc))
                                        return -1;