patch 'net/hns3: fix memory leak on failure' has been queued to stable release 23.11.5
Xueming Li
xuemingl at nvidia.com
Thu Jun 26 14:00:55 CEST 2025
Hi,
FYI, your patch has been queued to stable release 23.11.5
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/28/25. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging
This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=bee4d0630908981173a4d6ca8ee174041e03d711
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From bee4d0630908981173a4d6ca8ee174041e03d711 Mon Sep 17 00:00:00 2001
From: Dengdui Huang <huangdengdui at huawei.com>
Date: Tue, 8 Apr 2025 16:30:55 +0800
Subject: [PATCH] net/hns3: fix memory leak on failure
Cc: Xueming Li <xuemingl at nvidia.com>
[ upstream commit 1c27385dcef1384a1a10edd86bb843b06547b161 ]
When the hns3_dfx_reg_fetch_data() function returns from processing
failure, cmd_descs is not freed, which leads to leakage.
This patch fit it.
By the way, this patch uses calloc to apply for heap memory instead
of hugepage memory.
Fixes: ef1fbd355451 ("net/hns3: add more registers to dump")
Signed-off-by: Dengdui Huang <huangdengdui at huawei.com>
---
drivers/net/hns3/hns3_regs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index 8c0c0a3027..c8b251ead8 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -444,7 +444,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, void **data)
for (i = 0; i < opcode_num; i++)
max_bd_num = RTE_MAX(bd_num_list[i], max_bd_num);
- cmd_descs = rte_zmalloc(NULL, sizeof(*cmd_descs) * max_bd_num, 0);
+ cmd_descs = calloc(max_bd_num, sizeof(*cmd_descs));
if (cmd_descs == NULL)
return -ENOMEM;
@@ -457,8 +457,9 @@ hns3_get_dfx_regs(struct hns3_hw *hw, void **data)
if (ret)
break;
reg_val += hns3_dfx_reg_fetch_data(cmd_descs, bd_num, reg_val);
+ free(cmd_descs);
}
- rte_free(cmd_descs);
+ free(cmd_descs);
*data = (void *)reg_val;
return ret;
--
2.34.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-06-26 19:59:19.281190965 +0800
+++ 0035-net-hns3-fix-memory-leak-on-failure.patch 2025-06-26 19:59:17.342418046 +0800
@@ -1 +1 @@
-From 1c27385dcef1384a1a10edd86bb843b06547b161 Mon Sep 17 00:00:00 2001
+From bee4d0630908981173a4d6ca8ee174041e03d711 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 1c27385dcef1384a1a10edd86bb843b06547b161 ]
@@ -14 +16,0 @@
-Cc: stable at dpdk.org
@@ -22 +24 @@
-index 8a6ddbfe8c..5c74f9ae2e 100644
+index 8c0c0a3027..c8b251ead8 100644
@@ -25 +27 @@
-@@ -1270,7 +1270,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, struct rte_dev_reg_info *regs, uint32_t mo
+@@ -444,7 +444,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, void **data)
@@ -34,4 +36,4 @@
-@@ -1290,13 +1290,14 @@ hns3_get_dfx_regs(struct hns3_hw *hw, struct rte_dev_reg_info *regs, uint32_t mo
- if (regs_num != hns3_reg_lists[i].entry_num) {
- hns3_err(hw, "Query register number differ from the list for module %s!",
- hns3_get_name_by_module(i));
+@@ -457,8 +457,9 @@ hns3_get_dfx_regs(struct hns3_hw *hw, void **data)
+ if (ret)
+ break;
+ reg_val += hns3_dfx_reg_fetch_data(cmd_descs, bd_num, reg_val);
@@ -39,5 +40,0 @@
- return -EINVAL;
- }
- hns3_fill_dfx_regs_name(hw, regs, hns3_reg_lists[i].reg_list, regs_num);
- regs->length += regs_num;
- data += regs_num;
@@ -46,0 +44 @@
+ *data = (void *)reg_val;
@@ -49 +46,0 @@
- }
More information about the stable
mailing list