From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
stable@dpdk.org,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
Ting Xu <ting.xu@intel.com>, Qi Zhang <qi.z.zhang@intel.com>,
Qiming Yang <qiming.yang@intel.com>,
Wenjun Wu <wenjun1.wu@intel.com>
Subject: [PATCH 1/2] net/iavf: fix local memory leaks in TM hierarchy commit
Date: Fri, 3 Jul 2026 09:33:34 +0100 [thread overview]
Message-ID: <20260703083335.4058936-1-bruce.richardson@intel.com> (raw)
The iavf_hierachy_commit function uses a number of temporary variables,
which, though small, are still leaked at function end. Clean this up by
freeing them before the function returns. Since these are not variables
that need to be in hugepage memory, also switch from using rte_zmalloc
to calloc.
Fixes: 44d0a720a538 ("net/iavf: query QoS capabilities and set queue TC mapping")
Fixes: 5779a8894d15 ("net/iavf: support queue rate limit configuration")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/iavf/iavf_tm.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf_tm.c b/drivers/net/intel/iavf/iavf_tm.c
index e3492ec491..cc5c86b4ce 100644
--- a/drivers/net/intel/iavf/iavf_tm.c
+++ b/drivers/net/intel/iavf/iavf_tm.c
@@ -2,6 +2,7 @@
* Copyright(c) 2010-2017 Intel Corporation
*/
#include <rte_tm_driver.h>
+#include <stdlib.h>
#include "iavf.h"
@@ -795,8 +796,8 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
struct iavf_adapter *adapter =
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
- struct virtchnl_queue_tc_mapping *q_tc_mapping;
- struct virtchnl_queues_bw_cfg *q_bw;
+ struct virtchnl_queue_tc_mapping *q_tc_mapping = NULL;
+ struct virtchnl_queues_bw_cfg *q_bw = NULL;
struct iavf_tm_node_list *queue_list = &vf->tm_conf.queue_list;
struct iavf_tm_node *tm_node;
struct iavf_qtc_map *qtc_map;
@@ -832,7 +833,7 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
size = sizeof(*q_tc_mapping) + sizeof(q_tc_mapping->tc[0]) *
(vf->qos_cap->num_elem - 1);
- q_tc_mapping = rte_zmalloc("q_tc", size, 0);
+ q_tc_mapping = calloc(1, size);
if (!q_tc_mapping) {
ret_val = IAVF_ERR_NO_MEMORY;
goto fail_clear;
@@ -840,7 +841,7 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
size_q = sizeof(*q_bw) + sizeof(q_bw->cfg[0]) *
(vf->num_queue_pairs - 1);
- q_bw = rte_zmalloc("q_bw", size_q, 0);
+ q_bw = calloc(1, size_q);
if (!q_bw) {
ret_val = IAVF_ERR_NO_MEMORY;
goto fail_clear;
@@ -889,8 +890,10 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
/* store the queue TC mapping info */
qtc_map = rte_zmalloc("qtc_map",
sizeof(struct iavf_qtc_map) * q_tc_mapping->num_tc, 0);
- if (!qtc_map)
- return IAVF_ERR_NO_MEMORY;
+ if (!qtc_map) {
+ ret_val = IAVF_ERR_NO_MEMORY;
+ goto fail_clear;
+ }
for (i = 0; i < q_tc_mapping->num_tc; i++) {
q_tc_mapping->tc[i].req.start_queue_id = index;
@@ -908,6 +911,8 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
vf->qtc_map = qtc_map;
if (adapter->stopped == 1)
vf->tm_conf.committed = true;
+ free(q_bw);
+ free(q_tc_mapping);
return ret_val;
fail_clear:
@@ -917,5 +922,7 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
iavf_tm_conf_init(dev);
}
err:
+ free(q_bw);
+ free(q_tc_mapping);
return ret_val;
}
--
2.53.0
next reply other threads:[~2026-07-03 8:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 8:33 Bruce Richardson [this message]
2026-07-03 8:33 ` [PATCH 2/2] net/iavf: fix leak of queue to traffic class mapping data Bruce Richardson
2026-07-03 13:19 ` [PATCH v2 0/6] Fix some small memory leaks Bruce Richardson
2026-07-03 13:19 ` [PATCH v2 1/6] net/iavf: fix local memory leaks in TM hierarchy commit Bruce Richardson
2026-07-03 13:19 ` [PATCH v2 2/6] net/iavf: fix leak of queue to traffic class mapping data Bruce Richardson
2026-07-03 13:19 ` [PATCH v2 3/6] net/iavf: fix memory leak on error when adding flow parser Bruce Richardson
2026-07-03 13:19 ` [PATCH v2 4/6] net/ice: fix buffer leak in config of Tx queue TM node Bruce Richardson
2026-07-03 13:19 ` [PATCH v2 5/6] net/iavf: fix leak of flex metadata extraction field Bruce Richardson
2026-07-03 13:19 ` [PATCH v2 6/6] net/iavf: fix leak of IPsec crypto capabilities array Bruce Richardson
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=20260703083335.4058936-1-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=qi.z.zhang@intel.com \
--cc=qiming.yang@intel.com \
--cc=stable@dpdk.org \
--cc=ting.xu@intel.com \
--cc=vladimir.medvedkin@intel.com \
--cc=wenjun1.wu@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