From: Wei Dai Date: Thu, 3 Nov 2016 10:15:59 +0000 (+0800) Subject: lpm: fix freeing memory X-Git-Tag: spdx-start~5398 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c7e9d6a6ed90a022067f42727d5d1675a3f3df11;p=dpdk.git 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") Signed-off-by: Morten Brørup Signed-off-by: Wei Dai --- diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index ec67765cbe..8c15c4c9ff 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -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);