[v2,06/25] net/bnxt: free the EM index on failure
diff mbox series

Message ID 20200916042851.32914-7-ajit.khaparde@broadcom.com
State Accepted
Delegated to: Ajit Khaparde
Headers show
Series
  • patchset for bnxt
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde Sept. 16, 2020, 4:28 a.m. UTC
From: Mike Baucom <michael.baucom@broadcom.com>

When a Exact Match entry fails insertion, the allocated index needs to
be pushed back to the allocation stack. This patch takes care of that.

Signed-off-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_em_internal.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 462d0fa76..c95515b1b 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -175,8 +175,11 @@  tf_em_insert_int_entry(struct tf *tfp,
 					     &rptr_index,
 					     &rptr_entry,
 					     &num_of_entries);
-	if (rc)
+	if (rc) {
+		/* Free the allocated index before returning */
+		stack_push(pool, index);
 		return -1;
+	}
 
 	PMD_DRV_LOG
 		  (DEBUG,