From: Christian Ehrhardt Date: Mon, 21 Mar 2016 14:06:13 +0000 (+0100) Subject: lpm: fix missing free X-Git-Tag: spdx-start~7244 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d4c18f0a1d5d03297a393b6bcda90e5acc27c710;p=dpdk.git lpm: fix missing free In rte_lpm_free lpm might not be freed if it didn't find a te (early return) The two lpm interfaces rte_lpm_free_v20 and rte_lpm_free_v1604 had a leak. rte_lpm_free_v20 might have missed to free rules_tbl rte_lpm_free_v1604 due to an early exit might have missed to free rules_tbl and lpm itself. Fixes: 899d8bc9b3b5 ("lpm: make tailq fully local") Signed-off-by: Christian Ehrhardt Acked-by: Bruce Richardson Acked-by: Olivier Matz --- diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index ccaaa2af3d..3dee15c5e0 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -360,15 +360,12 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm) if (te->data == (void *) lpm) break; } - if (te == NULL) { - rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); - return; - } - - TAILQ_REMOVE(lpm_list, te, next); + if (te != NULL) + TAILQ_REMOVE(lpm_list, te, next); rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_free(lpm->rules_tbl); rte_free(lpm); rte_free(te); } @@ -393,15 +390,12 @@ rte_lpm_free_v1604(struct rte_lpm *lpm) if (te->data == (void *) lpm) break; } - if (te == NULL) { - rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); - return; - } - - TAILQ_REMOVE(lpm_list, te, next); + if (te != NULL) + TAILQ_REMOVE(lpm_list, te, next); rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_free(lpm->rules_tbl); rte_free(lpm); rte_free(te); }