[dpdk-dev,v3] vhost: Fix wrong handling of virtqueue array index

Message ID 1446004060-29198-1-git-send-email-mukawa@igel.co.jp (mailing list archive)
State Accepted, archived
Headers

Commit Message

Tetsuya Mukawa Oct. 28, 2015, 3:47 a.m. UTC
  The patch fixes wrong handling of virtqueue array index when
GET_VRING_BASE message comes.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
  

Comments

Huawei Xie Oct. 28, 2015, 5:29 a.m. UTC | #1
On 10/28/2015 11:48 AM, Tetsuya Mukawa wrote:
> The patch fixes wrong handling of virtqueue array index when
> GET_VRING_BASE message comes.
>
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Huawei Xie <huawei.xie@intel.com>
> ---
  
Flavio Leitner Oct. 29, 2015, 10:18 p.m. UTC | #2
On Wed, Oct 28, 2015 at 12:47:40PM +0900, Tetsuya Mukawa wrote:
> The patch fixes wrong handling of virtqueue array index when
> GET_VRING_BASE message comes.
> 
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
> ---

vhost-user segfaults without this patch with MQ enabled.
LGTM

Acked-by: Flavio Leitner <fbl@sysclose.org>
  
Thomas Monjalon Oct. 30, 2015, 2:48 p.m. UTC | #3
2015-10-29 20:18, Flavio Leitner:
> On Wed, Oct 28, 2015 at 12:47:40PM +0900, Tetsuya Mukawa wrote:
> > The patch fixes wrong handling of virtqueue array index when
> > GET_VRING_BASE message comes.
> > 
> > Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
> > ---
> 
> vhost-user segfaults without this patch with MQ enabled.
> LGTM
> 
> Acked-by: Flavio Leitner <fbl@sysclose.org>

Applied, thanks

Note: the priority would have been different if the title was
	vhost: fix crash with multiqueue enabled
(as committed)
  

Patch

diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
index a998ad8..d07452a 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -300,13 +300,9 @@  user_get_vring_base(struct vhost_device_ctx ctx,
 	 * sent and only sent in vhost_vring_stop.
 	 * TODO: cleanup the vring, it isn't usable since here.
 	 */
-	if (dev->virtqueue[state->index + VIRTIO_RXQ]->kickfd >= 0) {
-		close(dev->virtqueue[state->index + VIRTIO_RXQ]->kickfd);
-		dev->virtqueue[state->index + VIRTIO_RXQ]->kickfd = -1;
-	}
-	if (dev->virtqueue[state->index + VIRTIO_TXQ]->kickfd >= 0) {
-		close(dev->virtqueue[state->index + VIRTIO_TXQ]->kickfd);
-		dev->virtqueue[state->index + VIRTIO_TXQ]->kickfd = -1;
+	if (dev->virtqueue[state->index]->kickfd >= 0) {
+		close(dev->virtqueue[state->index]->kickfd);
+		dev->virtqueue[state->index]->kickfd = -1;
 	}
 
 	return 0;