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 4A9B0A0573; Thu, 5 Mar 2020 03:54:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BCCB72C16; Thu, 5 Mar 2020 03:54:52 +0100 (CET) Received: from valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by dpdk.org (Postfix) with ESMTP id 69C172C02; Thu, 5 Mar 2020 03:54:51 +0100 (CET) Received: by valinux.co.jp (Postfix, from userid 1000) id 994FC2408CF; Thu, 5 Mar 2020 11:54:50 +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, stable@dpdk.org Date: Thu, 5 Mar 2020 11:54:50 +0900 Message-Id: <20200305025450.5498-1-oda@valinux.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303000329.823-1-oda@valinux.co.jp> References: <20200303000329.823-1-oda@valinux.co.jp> Subject: [dpdk-dev] [PATCH v3] 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 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 --- v2: - fix commit message v3: - fix spell error of Reviewed-by 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