From 391b5f425c4613e649e5353ed8161e75967b0f3a Mon Sep 17 00:00:00 2001 From: Huawei Xie Date: Tue, 3 Mar 2015 10:26:04 +0800 Subject: [PATCH] vhost: fix crash by removing device when requested This patch fixes the segfault issue in the case vhost receives new VHOST_SET_MEM_TABLE message without VHOST_VRING_GET_VRING_BASE (which we uses as the stop message). Signed-off-by: Huawei Xie Acked-by: Tommy Long --- lib/librte_vhost/vhost_user/virtio-net-user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c index 97c517742f..aa087063d6 100644 --- a/lib/librte_vhost/vhost_user/virtio-net-user.c +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c @@ -109,6 +109,10 @@ user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg) if (dev == NULL) return -1; + /* Remove from the data plane. */ + if (dev->flags & VIRTIO_DEV_RUNNING) + notify_ops->destroy_device(dev); + if (dev->mem) { free_mem_region(dev); free(dev->mem); -- 2.20.1