From: Itsuro Oda Date: Thu, 5 Mar 2020 02:54:50 +0000 (+0900) Subject: net/vhost: fix potential memory leak on close X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=770fabcd36ec11d64544e86ed7d2dda9f5c64daf;p=dpdk.git 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: 3d01b759d267 ("net/vhost: delay driver setup") Cc: stable@dpdk.org Signed-off-by: Itsuro Oda Reviewed-by: Xiaolong Ye --- diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index f44e6bbebe..808e670f13 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -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++)