[PATCH] pipeline: fix double free error for table stats

kamalakannan R kamalakannan.r at intel.com
Mon Apr 17 08:31:10 CEST 2023


From: kamalakannanr89 <kamalakannan.r at intel.com>

The pointer to the table statistics data structure needs to be set
to NULL after free inside the table_build_free(), as this function is
called from multiple places, leading to double memory free error.

Similar fix for the learner_build_free() function.

Fixes: 742b0a57f50 ("pipeline: add table statistics to SWX")
Fixes: 4f59d372614 ("pipeline: support learner tables")

Signed-off-by: Kamalakannan R <kamalakannan.r at intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu at intel.com>
---
 lib/pipeline/rte_swx_pipeline.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index dea1378095..da37eda231 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -8665,6 +8665,7 @@ table_build_free(struct rte_swx_pipeline *p)
 			free(p->table_stats[i].n_pkts_action);
 
 		free(p->table_stats);
+		p->table_stats = NULL;
 	}
 }
 
@@ -9579,6 +9580,7 @@ learner_build_free(struct rte_swx_pipeline *p)
 			free(p->learner_stats[i].n_pkts_action);
 
 		free(p->learner_stats);
+		p->learner_stats = NULL;
 	}
 }
 
-- 
2.34.3



More information about the stable mailing list