1 Star 0 Fork 72

hantwofish/dpdk

forked from src-openEuler/dpdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0039-net-hns3-fix-double-free-for-Rx-Tx-queue.patch 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
huangdengdui 提交于 2024-05-10 16:25 . sync some patch from upstreaming
From 5f3efed4c06e8d68aa2089db660c4c23b21df291 Mon Sep 17 00:00:00 2001
From: Dengdui Huang <huangdengdui@huawei.com>
Date: Wed, 3 Apr 2024 18:16:21 +0800
Subject: [PATCH 39/42] net/hns3: fix double free for Rx/Tx queue
[ upstream commit 833a5beab5bfc16708ee9b53c83e2f221cd99f90 ]
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 bba29a9..d43cc96 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.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hantwofish/dpdk.git
git@gitee.com:hantwofish/dpdk.git
hantwofish
dpdk
dpdk
master

搜索帮助