net/vhost: fix potential memory leak on close

If a vhost device is closed before eth_dev_configure is done
to the device, internal resources allocated to the device
would not be freed. This patch fixes it.

Fixes: 3d01b759d2 ("net/vhost: delay driver setup")
Cc: stable@dpdk.org

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
This commit is contained in:
Itsuro Oda 2020-03-05 11:54:50 +09:00 committed by Ferruh Yigit
parent a2154606ff
commit 770fabcd36

View File

@ -1069,16 +1069,14 @@ eth_dev_close(struct rte_eth_dev *dev)
eth_dev_stop(dev);
rte_vhost_driver_unregister(internal->iface_name);
list = find_internal_resource(internal->iface_name);
if (!list)
return;
pthread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
pthread_mutex_unlock(&internal_list_lock);
rte_free(list);
if (list) {
rte_vhost_driver_unregister(internal->iface_name);
pthread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
pthread_mutex_unlock(&internal_list_lock);
rte_free(list);
}
if (dev->data->rx_queues)
for (i = 0; i < dev->data->nb_rx_queues; i++)