[1/6] vhost: fix desc access in relay helpers

Message ID 20190104040642.27463-2-tiwei.bie@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series Some fixes for vhost |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Tiwei Bie Jan. 4, 2019, 4:06 a.m. UTC
  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>
---
 lib/librte_vhost/vdpa.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Comments

Maxime Coquelin Jan. 4, 2019, 8:16 a.m. UTC | #1
On 1/4/19 5:06 AM, Tiwei Bie wrote:
> 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>
> ---
>   lib/librte_vhost/vdpa.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)

Good catch!

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c
index 240a1fe3a..77d92f9ad 100644
--- a/lib/librte_vhost/vdpa.c
+++ b/lib/librte_vhost/vdpa.c
@@ -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;