Skip to content

Commit

Permalink
ipv6: Fix fib6_dump_table walker leak
Browse files Browse the repository at this point in the history
When a fib6 table dump is prematurely ended, we won't unlink
its walker from the list.  This causes all sorts of grief for
other users of the list later.

Reported-by: Chris Caputo <ccaputo@alt.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Jan 14, 2009
1 parent 33966dd commit 7891cc8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions net/ipv6/ip6_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ static void fib6_dump_end(struct netlink_callback *cb)
struct fib6_walker_t *w = (void*)cb->args[2];

if (w) {
if (cb->args[4]) {
cb->args[4] = 0;
fib6_walker_unlink(w);
}
cb->args[2] = 0;
kfree(w);
}
Expand Down Expand Up @@ -330,15 +334,12 @@ static int fib6_dump_table(struct fib6_table *table, struct sk_buff *skb,
read_lock_bh(&table->tb6_lock);
res = fib6_walk_continue(w);
read_unlock_bh(&table->tb6_lock);
if (res != 0) {
if (res < 0)
fib6_walker_unlink(w);
goto end;
if (res <= 0) {
fib6_walker_unlink(w);
cb->args[4] = 0;
}
fib6_walker_unlink(w);
cb->args[4] = 0;
}
end:

return res;
}

Expand Down

0 comments on commit 7891cc8

Please sign in to comment.