1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-27 11:55:06 +00:00

pf: Fix memory leak in DIOCRADDTABLES

If a user attempts to add two tables with the same name the duplicate table
will not be added, but we forgot to free the duplicate table, leaking memory.
Ensure we free the duplicate table in the error path.

Reported by:	Coverity
CID:		1382111
MFC after:	3 weeks
This commit is contained in:
Kristof Provost 2018-03-19 21:13:25 +00:00
parent 7d48aa4c72
commit b4b8fa3387
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331225

View File

@ -1131,8 +1131,10 @@ pfr_add_tables(struct pfr_table *tbl, int size, int *nadd, int flags)
if (p == NULL)
senderr(ENOMEM);
SLIST_FOREACH(q, &addq, pfrkt_workq) {
if (!pfr_ktable_compare(p, q))
if (!pfr_ktable_compare(p, q)) {
pfr_destroy_ktable(p, 0);
goto _skip;
}
}
SLIST_INSERT_HEAD(&addq, p, pfrkt_workq);
xadd++;