diff options
author | David S. Miller <davem@davemloft.net> | 2005-08-05 07:12:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-08-05 07:12:48 -0400 |
commit | b7656e7f2944984befa3ab99a5b99f99a23b302b (patch) | |
tree | bd7281aac296d0d0f7eac7989726f540318236fc /net | |
parent | 2f60f8d3573ff90fe5d75a6d11fd2add1248e7d6 (diff) |
[IPV4]: Fix memory leak during fib_info hash expansion.
When we grow the tables, we forget to free the olds ones
up.
Noticed by Yan Zheng.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/fib_semantics.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index c886b28ba9f5..e278cb9d0075 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -593,10 +593,13 @@ static void fib_hash_move(struct hlist_head *new_info_hash, | |||
593 | struct hlist_head *new_laddrhash, | 593 | struct hlist_head *new_laddrhash, |
594 | unsigned int new_size) | 594 | unsigned int new_size) |
595 | { | 595 | { |
596 | struct hlist_head *old_info_hash, *old_laddrhash; | ||
596 | unsigned int old_size = fib_hash_size; | 597 | unsigned int old_size = fib_hash_size; |
597 | unsigned int i; | 598 | unsigned int i, bytes; |
598 | 599 | ||
599 | write_lock(&fib_info_lock); | 600 | write_lock(&fib_info_lock); |
601 | old_info_hash = fib_info_hash; | ||
602 | old_laddrhash = fib_info_laddrhash; | ||
600 | fib_hash_size = new_size; | 603 | fib_hash_size = new_size; |
601 | 604 | ||
602 | for (i = 0; i < old_size; i++) { | 605 | for (i = 0; i < old_size; i++) { |
@@ -636,6 +639,10 @@ static void fib_hash_move(struct hlist_head *new_info_hash, | |||
636 | fib_info_laddrhash = new_laddrhash; | 639 | fib_info_laddrhash = new_laddrhash; |
637 | 640 | ||
638 | write_unlock(&fib_info_lock); | 641 | write_unlock(&fib_info_lock); |
642 | |||
643 | bytes = old_size * sizeof(struct hlist_head *); | ||
644 | fib_hash_free(old_info_hash, bytes); | ||
645 | fib_hash_free(old_laddrhash, bytes); | ||
639 | } | 646 | } |
640 | 647 | ||
641 | struct fib_info * | 648 | struct fib_info * |