Skip to content

Commit

Permalink
netfilter: ipset: list:set: fix reference counter update
Browse files Browse the repository at this point in the history
The last element can be replaced or pushed off and in both
cases the reference counter must be updated.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Jozsef Kadlecsik authored and Pablo Neira Ayuso committed Apr 9, 2013
1 parent 3a7b21e commit 02f815c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/netfilter/ipset/ip_set_list_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,13 @@ list_set_add(struct list_set *map, u32 i, ip_set_id_t id,
{
const struct set_elem *e = list_set_elem(map, i);

if (i == map->size - 1 && e->id != IPSET_INVALID_ID)
/* Last element replaced: e.g. add new,before,last */
ip_set_put_byindex(e->id);
if (e->id != IPSET_INVALID_ID) {
const struct set_elem *x = list_set_elem(map, map->size - 1);

/* Last element replaced or pushed off */
if (x->id != IPSET_INVALID_ID)
ip_set_put_byindex(x->id);
}
if (with_timeout(map->timeout))
list_elem_tadd(map, i, id, ip_set_timeout_set(timeout));
else
Expand Down

0 comments on commit 02f815c

Please sign in to comment.