vhost: fix off-by-one error on descriptor number check
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Mon, 25 Jul 2016 14:09:58 +0000 (16:09 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 25 Jul 2016 15:55:12 +0000 (17:55 +0200)
nr_desc is not an index but the number of descriptors,
so can be equal to the virtqueue size.

Fixes: a436f53ebfeb ("vhost: avoid dead loop chain")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
lib/librte_vhost/vhost_rxtx.c

index bc00518..08a73fd 100644 (file)
@@ -748,7 +748,7 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,
                                break;
 
                        if (unlikely(desc->next >= vq->size ||
-                                    ++nr_desc >= vq->size))
+                                    ++nr_desc > vq->size))
                                return -1;
                        desc = &vq->desc[desc->next];