vhost: fix crash by removing device when requested
authorHuawei Xie <huawei.xie@intel.com>
Tue, 3 Mar 2015 02:26:04 +0000 (10:26 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 5 Mar 2015 21:08:27 +0000 (22:08 +0100)
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 <huawei.xie@intel.com>
Acked-by: Tommy Long <thomas.long@intel.com>
lib/librte_vhost/vhost_user/virtio-net-user.c

index 97c5177..aa08706 100644 (file)
@@ -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);