patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Itsuro Oda <oda@valinux.co.jp>
To: maxime.coquelin@redhat.com, tiwei.bie@intel.com,
	zhihong.wang@intel.com, anatoly.burakov@intel.com, dev@dpdk.org,
	stable@dpdk.org
Subject: [dpdk-stable] [PATCH v2] net/vhost: fix potential memory leak
Date: Thu,  5 Mar 2020 11:50:52 +0900	[thread overview]
Message-ID: <20200305025052.5368-1-oda@valinux.co.jp> (raw)
In-Reply-To: <20200303000329.823-1-oda@valinux.co.jp>

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 <oda@valinux.co.jp>
Reviewd-by: Xiaolong Ye <xiaolong.ye@intel.com>
---
v2:
- fix commit message

 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


       reply	other threads:[~2020-03-05  2:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200303000329.823-1-oda@valinux.co.jp>
2020-03-05  2:50 ` Itsuro Oda [this message]
2020-03-05  2:54 ` [dpdk-stable] [PATCH v3] " Itsuro Oda
2020-03-19 17:15   ` [dpdk-stable] [dpdk-dev] " Kevin Traynor
2020-03-20 16:23     ` Maxime Coquelin
2020-03-20 19:25       ` Kevin Traynor
2020-04-10 14:44   ` [dpdk-stable] " Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200305025052.5368-1-oda@valinux.co.jp \
    --to=oda@valinux.co.jp \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=tiwei.bie@intel.com \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).