* [dpdk-stable] [PATCH 19.11] net/bnxt: fix memory leak when freeing VF info
@ 2020-11-04 4:14 wangyunjian
2020-11-05 9:42 ` Luca Boccassi
0 siblings, 1 reply; 2+ messages in thread
From: wangyunjian @ 2020-11-04 4:14 UTC (permalink / raw)
To: stable
Cc: ajit.khaparde, somnath.kotur, luca.boccassi, jerry.lilijun,
xudingke, Yunjian Wang
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 a94b73623..1b1f130ed 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -4953,8 +4953,7 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev)
if (eth_dev->data->dev_started)
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 1fcba9955..5e7b7f006 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -589,6 +589,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;
@@ -615,7 +629,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_zmalloc("bnxt_vf_info",
sizeof(bp->pf.vf_info[0]) * new_max_vfs, 0);
if (bp->pf.vf_info == NULL) {
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index e647993af..8ceaeb59c 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -89,6 +89,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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-stable] [PATCH 19.11] net/bnxt: fix memory leak when freeing VF info
2020-11-04 4:14 [dpdk-stable] [PATCH 19.11] net/bnxt: fix memory leak when freeing VF info wangyunjian
@ 2020-11-05 9:42 ` Luca Boccassi
0 siblings, 0 replies; 2+ messages in thread
From: Luca Boccassi @ 2020-11-05 9:42 UTC (permalink / raw)
To: wangyunjian, stable; +Cc: ajit.khaparde, somnath.kotur, jerry.lilijun, xudingke
On Wed, 2020-11-04 at 12:14 +0800, wangyunjian wrote:
> 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(-)
Acked-by: Luca Boccassi <luca.boccassi@microsoft.com>
Thanks, applied and pushed.
--
Kind regards,
Luca Boccassi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-05 9:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-04 4:14 [dpdk-stable] [PATCH 19.11] net/bnxt: fix memory leak when freeing VF info wangyunjian
2020-11-05 9:42 ` Luca Boccassi
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).