[2/2] net/bnxt: fix freeing of representor info memory

Message ID 20220927155902.29850-2-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers
Series [1/2] net/bnxt: remove unnecessary check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS

Commit Message

Kalesh A P Sept. 27, 2022, 3:59 p.m. UTC
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

Driver allocates "bp->rep_info" inside bnxt_init_rep_info() which is
invoked from bnxt_rep_port_probe(). But the memory is freed inside
bnxt_uninit_resources(), which is wrong. As a result, after error
recovery bp->rep_info will be NULL. The memory should have freed inside
bnxt_drv_uninit() to maintain symmetry of calls.

Fixes: 6dc83230b43b ("net/bnxt: support port representor data path")
Cc: stable@dpdk.org

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ajit Khaparde Oct. 4, 2022, 3:59 a.m. UTC | #1
On Tue, Sep 27, 2022 at 9:00 AM Kalesh A P
<kalesh-anakkur.purayil@broadcom.com> wrote:
>
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>
> Driver allocates "bp->rep_info" inside bnxt_init_rep_info() which is
> invoked from bnxt_rep_port_probe(). But the memory is freed inside
> bnxt_uninit_resources(), which is wrong. As a result, after error
> recovery bp->rep_info will be NULL. The memory should have freed inside
> bnxt_drv_uninit() to maintain symmetry of calls.
>
> Fixes: 6dc83230b43b ("net/bnxt: support port representor data path")
> Cc: stable@dpdk.org
>
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Patch applied to dpdk-next-net-brcm, Thanks
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 84cf9a3..b033ad7 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1654,6 +1654,7 @@  static void bnxt_drv_uninit(struct bnxt *bp)
 	bnxt_free_link_info(bp);
 	bnxt_free_parent_info(bp);
 	bnxt_uninit_locks(bp);
+	bnxt_free_rep_info(bp);
 
 	rte_memzone_free((const struct rte_memzone *)bp->tx_mem_zone);
 	bp->tx_mem_zone = NULL;
@@ -5978,7 +5979,6 @@  bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
 
 	bnxt_free_flow_stats_info(bp);
 	bnxt_free_switch_domain(bp);
-	bnxt_free_rep_info(bp);
 	rte_free(bp->ptp_cfg);
 	bp->ptp_cfg = NULL;
 	return rc;