From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 85761A056F; Tue, 3 Mar 2020 01:03:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CD74E1BFF3; Tue, 3 Mar 2020 01:03:32 +0100 (CET) Received: from valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by dpdk.org (Postfix) with ESMTP id A568F1BFF0 for ; Tue, 3 Mar 2020 01:03:30 +0100 (CET) Received: by valinux.co.jp (Postfix, from userid 1000) id 86BD8240971; Tue, 3 Mar 2020 09:03:29 +0900 (JST) From: Itsuro Oda To: maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com, anatoly.burakov@intel.com, dev@dpdk.org Date: Tue, 3 Mar 2020 09:03:29 +0900 Message-Id: <20200303000329.823-1-oda@valinux.co.jp> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/vhost: fix potential memory leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If a vhost device is closed before eth_dev_configure is done to the device, internal resources allocated to the device does not freed. This patch fixes it. Fixes: 3d01b759d267 ("net/vhost: delay driver setup") Signed-off-by: Itsuro Oda --- drivers/net/vhost/rte_eth_vhost.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 458ed58f5..1ed977e9b 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -1065,16 +1065,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++) -- 2.17.0