Skip to contentSkip to conversation

lpm: fix freeing memory

PATCH Applied Wei Dai 2 participants 2 messages Nov 3, 2016 – Nov 6, 2016

lore
Share & tools
lore

Wei Dai

author
#0 lore raw

PATCH 1/1 lpm: fix freeing memory

The memory pointed by lpm->rules_tbl should also be freed when memory malloc for tbl8 fails in rte_lpm_create_v1604( ). And the memory pointed by lpm->tbl8 should also be freed when the lpm object is freed in rte_lpm_free_v1604( ).

Fixes f1f7261838b3 ("lpm: add a new config structure for IPv4")
---
 lib/librte_lpm/rte_lpm.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_lpm/rte_lpm.c +2 -0
index ec67765..8c15c4c 100644
@@ -321,6 +321,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 
 	if (lpm->tbl8 == NULL) {
 		RTE_LOG(ERR, LPM, "LPM tbl8 memory allocation failed\n");
+		rte_free(lpm->rules_tbl);
 		rte_free(lpm);
 		lpm = NULL;
 		rte_free(te);
@@ -402,6 +403,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 
 	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
 
+	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
 	rte_free(lpm);
 	rte_free(te);
Signature · 1 line
2.7.4
#1 lore raw

2016-11-03 18:15, Wei Dai:

Quoted 9 lines

The memory pointed by lpm->rules_tbl should also be freed when memory malloc for tbl8 fails in rte_lpm_create_v1604( ). And the memory pointed by lpm->tbl8 should also be freed when the lpm object is freed in rte_lpm_free_v1604( ).

Fixes f1f7261838b3 ("lpm: add a new config structure for IPv4")

Applied, thanks