DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lijun Ou <oulijun@huawei.com>
To: <thomas@monjalon.net>, <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>, <linuxarm@openeuler.org>
Subject: [dpdk-dev] [PATCH 08/14] net/hns3: fix memory leak with secondary process exit
Date: Fri, 22 Jan 2021 18:18:46 +0800	[thread overview]
Message-ID: <1611310732-51975-9-git-send-email-oulijun@huawei.com> (raw)
In-Reply-To: <1611310732-51975-1-git-send-email-oulijun@huawei.com>

the secondary process is applied a memory for the process_private
during initialization. Therefore, the memory needs to be released
when exiting.

Fixes: c203571b3602 ("net/hns3: register and add log interface")
Cc: stable@dpdk.org

Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c    |  7 +++++--
 drivers/net/hns3/hns3_ethdev_vf.c | 12 +++++++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 817d1dc..2a5689c 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -6263,8 +6263,11 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev)
 
 	PMD_INIT_FUNC_TRACE();
 
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-		return -EPERM;
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		rte_free(eth_dev->process_private);
+		eth_dev->process_private = NULL;
+		return 0;
+	}
 
 	if (hw->adapter_state < HNS3_NIC_CLOSING)
 		hns3_dev_close(eth_dev);
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 3a1d4cb..948d914 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1971,8 +1971,11 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev)
 	struct hns3_hw *hw = &hns->hw;
 	int ret = 0;
 
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		rte_free(eth_dev->process_private);
+		eth_dev->process_private = NULL;
 		return 0;
+	}
 
 	if (hw->adapter_state == HNS3_NIC_STARTED)
 		ret = hns3vf_dev_stop(eth_dev);
@@ -2839,8 +2842,11 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev)
 
 	PMD_INIT_FUNC_TRACE();
 
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-		return -EPERM;
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		rte_free(eth_dev->process_private);
+		eth_dev->process_private = NULL;
+		return 0;
+	}
 
 	if (hw->adapter_state < HNS3_NIC_CLOSING)
 		hns3vf_dev_close(eth_dev);
-- 
2.7.4


  parent reply	other threads:[~2021-01-22 10:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 10:18 [dpdk-dev] [PATCH 00/14] Misc updates for hns3 Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 01/14] net/hns3: encapsulate dfx stats in Rx/Tx datapatch Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 02/14] net/hns3: move queue stats to xstats Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 03/14] net/hns3: use array instead of switch-case Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 04/14] net/hns3: move judgment conditions to separated functions Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 05/14] net/hns3: reconstruct the Rx interrupt map Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 06/14] net/hns3: extract common judgments for all FDIR type Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 07/14] net/hns3: refactor reset event report function Lijun Ou
2021-01-22 10:18 ` Lijun Ou [this message]
2021-01-22 10:18 ` [dpdk-dev] [PATCH 09/14] net/hns3: fix interrupt resources in Rx interrupt mode Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 10/14] net/hns3: rename RSS functions Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 11/14] net/hns3: adjust some comments Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 12/14] net/hns3: remove unnecessary parentheses Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 13/14] net/hns3: use %d instead of %u for enum variable Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 14/14] net/hns3: support LSC event report Lijun Ou
2021-01-28 23:41   ` Ferruh Yigit
2021-01-29  1:49     ` oulijun
2021-02-02 12:06       ` Ferruh Yigit
2021-02-02 12:12   ` Ferruh Yigit
2021-01-28 23:58 ` [dpdk-dev] [PATCH 00/14] Misc updates for hns3 Ferruh Yigit

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=1611310732-51975-9-git-send-email-oulijun@huawei.com \
    --to=oulijun@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=linuxarm@openeuler.org \
    --cc=thomas@monjalon.net \
    /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).