From: Tiwei Bie Date: Mon, 19 Aug 2019 11:34:55 +0000 (+0800) Subject: vhost: forbid reallocation when running X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=37f7c1b609b67d26cbdd4c16a3ebc85e8d63e6dd;p=dpdk.git vhost: forbid reallocation when running When the device has been started, don't do the reallocation anymore. Otherwise the pointers used in application threads can be invalidated without proper protection. Instead of introducing a global lock to protect the change of device pointers which will hurt the performance, let's just do the reallocation during setup. Fixes: af295ad4698c ("vhost: realloc device and queues to same numa node as vring desc") Cc: stable@dpdk.org Reported-by: Yinan Wang Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin --- diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index f468436103..e4ae027a05 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -410,6 +410,9 @@ numa_realloc(struct virtio_net *dev, int index) struct batch_copy_elem *new_batch_copy_elems; int ret; + if (dev->flags & VIRTIO_DEV_RUNNING) + return dev; + old_dev = dev; vq = old_vq = dev->virtqueue[index];