[PATCH 05/20] net/bnxt: fix a memory leak in error handling

Weiguo Li liwg06 at foxmail.com
Tue Feb 22 19:18:03 CET 2022


When run goto from this branch, the 'ulp_fc_info' has not set into
the context yet, so ulp_fc_mgr_deinit(ctxt) in the error label can
not release 'ulp_fc_info' in this case which cause a memory leak.

Fixes: 9cf9c8385df7 ("net/bnxt: add ULP flow counter manager")

Signed-off-by: Weiguo Li <liwg06 at foxmail.com>
---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index 85c9cbb7f2..b055463ea4 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -86,6 +86,7 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt)
 
 	rc = pthread_mutex_init(&ulp_fc_info->fc_lock, NULL);
 	if (rc) {
+		rte_free(ulp_fc_info);
 		PMD_DRV_LOG(ERR, "Failed to initialize fc mutex\n");
 		goto error;
 	}
-- 
2.25.1



More information about the dev mailing list