From: Jie Hai <haijie1@huawei.com>
To: <dev@dpdk.org>, Yisen Zhuang <yisen.zhuang@huawei.com>,
Hao Chen <chenh@yusur.tech>,
"Wei Hu (Xavier)" <xavier.huwei@huawei.com>,
"Min Wang (Jushui)" <wangmin3@huawei.com>,
"Min Hu (Connor)" <humin29@huawei.com>,
Huisong Li <lihuisong@huawei.com>
Cc: <fengchengwen@huawei.com>, <liuyonglong@huawei.com>,
<huangdengdui@huawei.com>, <haijie1@huawei.com>
Subject: [PATCH 3/5] net/hns3: fix double free for Rx/Tx queue
Date: Wed, 3 Apr 2024 18:16:21 +0800 [thread overview]
Message-ID: <20240403101624.2771140-4-haijie1@huawei.com> (raw)
In-Reply-To: <20240403101624.2771140-1-haijie1@huawei.com>
From: Dengdui Huang <huangdengdui@huawei.com>
The Pointers to some resources on the Rx/Tx queue need to be set to NULL
after free inside the hns3_rx/tx_queue_release(), as this function is
called from multiple threads (reset thread, device config thread, etc),
leading to double memory free error.
Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
Cc: stable@dpdk.org
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 54bf724a0e6c..fbc5ef3225c5 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -86,9 +86,14 @@ hns3_rx_queue_release(void *queue)
struct hns3_rx_queue *rxq = queue;
if (rxq) {
hns3_rx_queue_release_mbufs(rxq);
- if (rxq->mz)
+ if (rxq->mz) {
rte_memzone_free(rxq->mz);
- rte_free(rxq->sw_ring);
+ rxq->mz = NULL;
+ }
+ if (rxq->sw_ring) {
+ rte_free(rxq->sw_ring);
+ rxq->sw_ring = NULL;
+ }
rte_free(rxq);
}
}
@@ -99,10 +104,18 @@ hns3_tx_queue_release(void *queue)
struct hns3_tx_queue *txq = queue;
if (txq) {
hns3_tx_queue_release_mbufs(txq);
- if (txq->mz)
+ if (txq->mz) {
rte_memzone_free(txq->mz);
- rte_free(txq->sw_ring);
- rte_free(txq->free);
+ txq->mz = NULL;
+ }
+ if (txq->sw_ring) {
+ rte_free(txq->sw_ring);
+ txq->sw_ring = NULL;
+ }
+ if (txq->free) {
+ rte_free(txq->free);
+ txq->free = NULL;
+ }
rte_free(txq);
}
}
--
2.30.0
next prev parent reply other threads:[~2024-04-03 10:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 10:16 [PATCH 0/5] net/hns3: add some bugfix Jie Hai
2024-04-03 10:16 ` [PATCH 1/5] net/hns3: fix offload flag of IEEE 1588 Jie Hai
2024-04-05 14:33 ` Patrick Robb
2024-04-03 10:16 ` [PATCH 2/5] net/hns3: fix read Rx timestamp handle Jie Hai
2024-04-03 10:16 ` Jie Hai [this message]
2024-04-03 10:16 ` [PATCH 4/5] net/hns3: fix variable overflow Jie Hai
2024-04-03 10:16 ` [PATCH 5/5] net/hns3: disable SCTP verification Tag for RSS hash input Jie Hai
2024-04-18 22:57 ` [PATCH 0/5] net/hns3: add some bugfix 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=20240403101624.2771140-4-haijie1@huawei.com \
--to=haijie1@huawei.com \
--cc=chenh@yusur.tech \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=huangdengdui@huawei.com \
--cc=humin29@huawei.com \
--cc=lihuisong@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=wangmin3@huawei.com \
--cc=xavier.huwei@huawei.com \
--cc=yisen.zhuang@huawei.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).