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 <christian.ehrhardt@canonical.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
This commit is contained in:
parent
42762a8062
commit
d4c18f0a1d
@ -360,15 +360,12 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
|
|||||||
if (te->data == (void *) lpm)
|
if (te->data == (void *) lpm)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (te == NULL) {
|
if (te != NULL)
|
||||||
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
|
TAILQ_REMOVE(lpm_list, te, next);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAILQ_REMOVE(lpm_list, te, next);
|
|
||||||
|
|
||||||
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
|
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
|
||||||
|
|
||||||
|
rte_free(lpm->rules_tbl);
|
||||||
rte_free(lpm);
|
rte_free(lpm);
|
||||||
rte_free(te);
|
rte_free(te);
|
||||||
}
|
}
|
||||||
@ -393,15 +390,12 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
|
|||||||
if (te->data == (void *) lpm)
|
if (te->data == (void *) lpm)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (te == NULL) {
|
if (te != NULL)
|
||||||
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
|
TAILQ_REMOVE(lpm_list, te, next);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAILQ_REMOVE(lpm_list, te, next);
|
|
||||||
|
|
||||||
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
|
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
|
||||||
|
|
||||||
|
rte_free(lpm->rules_tbl);
|
||||||
rte_free(lpm);
|
rte_free(lpm);
|
||||||
rte_free(te);
|
rte_free(te);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user