[16/17] net/bnxt: fix a possible memory leak

Message ID 20191024074432.30705-17-somnath.kotur@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers
Series bnxt patchset with bug fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Somnath Kotur Oct. 24, 2019, 7:44 a.m. UTC
  From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

During hot fw upgrade or error recovery, driver does cleanup and
reallocation of resources. But driver reallocates memory for ring
group info table without freeing the allocated memory during
device init.

Fix this memory leak by moving the freeing of ring group info table
to bnxt_free_mem() in bnxt_uninit_resources().

Fixes: 4617e2125c7f ("net/bnxt: refactor init and uninit functions")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 013b968..9642796 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -183,6 +183,9 @@  static void bnxt_free_mem(struct bnxt *bp, bool reconfig)
 	}
 	bnxt_free_async_cp_ring(bp);
 	bnxt_free_rxtx_nq_ring(bp);
+
+	rte_free(bp->grp_info);
+	bp->grp_info = NULL;
 }
 
 static int bnxt_alloc_mem(struct bnxt *bp, bool reconfig)
@@ -4821,11 +4824,6 @@  bnxt_dev_uninit(struct rte_eth_dev *eth_dev)
 
 	rc = bnxt_uninit_resources(bp, false);
 
-	if (bp->grp_info != NULL) {
-		rte_free(bp->grp_info);
-		bp->grp_info = NULL;
-	}
-
 	if (bp->tx_mem_zone) {
 		rte_memzone_free((const struct rte_memzone *)bp->tx_mem_zone);
 		bp->tx_mem_zone = NULL;