From: wangyunjian <wangyunjian@huawei.com>
To: <stable@dpdk.org>
Cc: <ktraynor@redhat.com>, <ajit.khaparde@broadcom.com>,
<jerry.lilijun@huawei.com>, <xudingke@huawei.com>,
Yunjian Wang <wangyunjian@huawei.com>
Subject: [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix memory leak when freeing VF info
Date: Wed, 25 Nov 2020 10:23:01 +0800 [thread overview]
Message-ID: <1606270981-59840-1-git-send-email-wangyunjian@huawei.com> (raw)
From: Yunjian Wang <wangyunjian@huawei.com>
[ upstream commit 9fb9a94caf48754e7643f32a5c419007c601d9f1 ]
When freeing a vf_info, we should free the 'vlan_as_table'
and 'vlan_table' for the vf_info.
Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
drivers/net/bnxt/bnxt_ethdev.c | 3 +--
drivers/net/bnxt/bnxt_hwrm.c | 16 +++++++++++++++-
drivers/net/bnxt/bnxt_hwrm.h | 1 +
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index c17fd3c55..82c54c3a7 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3520,8 +3520,7 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev)
if (bp->dev_stopped == 0)
bnxt_dev_close_op(eth_dev);
- if (bp->pf.vf_info)
- rte_free(bp->pf.vf_info);
+ bnxt_hwrm_free_vf_info(bp);
eth_dev->dev_ops = NULL;
eth_dev->rx_pkt_burst = NULL;
eth_dev->tx_pkt_burst = NULL;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index cf6f6d292..7c8ec7136 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -507,6 +507,20 @@ static int bnxt_hwrm_ptp_qcfg(struct bnxt *bp)
return 0;
}
+void bnxt_hwrm_free_vf_info(struct bnxt *bp)
+{
+ uint16_t i;
+
+ for (i = 0; i < bp->pf.max_vfs; i++) {
+ rte_free(bp->pf.vf_info[i].vlan_table);
+ bp->pf.vf_info[i].vlan_table = NULL;
+ rte_free(bp->pf.vf_info[i].vlan_as_table);
+ bp->pf.vf_info[i].vlan_as_table = NULL;
+ }
+ rte_free(bp->pf.vf_info);
+ bp->pf.vf_info = NULL;
+}
+
static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
{
int rc = 0;
@@ -533,7 +547,7 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
new_max_vfs = bp->pdev->max_vfs;
if (new_max_vfs != bp->pf.max_vfs) {
if (bp->pf.vf_info)
- rte_free(bp->pf.vf_info);
+ bnxt_hwrm_free_vf_info(bp);
bp->pf.vf_info = rte_malloc("bnxt_vf_info",
sizeof(bp->pf.vf_info[0]) * new_max_vfs, 0);
bp->pf.max_vfs = new_max_vfs;
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 0300bae4a..eadd3d64c 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -60,6 +60,7 @@ int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp);
int bnxt_hwrm_func_buf_unrgtr(struct bnxt *bp);
int bnxt_hwrm_func_driver_register(struct bnxt *bp);
int bnxt_hwrm_func_qcaps(struct bnxt *bp);
+void bnxt_hwrm_free_vf_info(struct bnxt *bp);
int bnxt_hwrm_func_reset(struct bnxt *bp);
int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags);
int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid,
--
2.18.1
reply other threads:[~2020-11-25 2:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1606270981-59840-1-git-send-email-wangyunjian@huawei.com \
--to=wangyunjian@huawei.com \
--cc=ajit.khaparde@broadcom.com \
--cc=jerry.lilijun@huawei.com \
--cc=ktraynor@redhat.com \
--cc=stable@dpdk.org \
--cc=xudingke@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).