summaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_semantics.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2005-08-05 04:12:48 -0700
committerDavid S. Miller <davem@davemloft.net>2005-08-05 04:12:48 -0700
commitb7656e7f2944984befa3ab99a5b99f99a23b302b (patch)
treebd7281aac296d0d0f7eac7989726f540318236fc /net/ipv4/fib_semantics.c
parent2f60f8d3573ff90fe5d75a6d11fd2add1248e7d6 (diff)
downloadlinux-b7656e7f2944984befa3ab99a5b99f99a23b302b.tar.gz
linux-b7656e7f2944984befa3ab99a5b99f99a23b302b.tar.bz2
linux-b7656e7f2944984befa3ab99a5b99f99a23b302b.zip
[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/ipv4/fib_semantics.c')
-rw-r--r--net/ipv4/fib_semantics.c9
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,
struct hlist_head *new_laddrhash,
unsigned int new_size)
{
+ struct hlist_head *old_info_hash, *old_laddrhash;
unsigned int old_size = fib_hash_size;
- unsigned int i;
+ unsigned int i, bytes;
write_lock(&fib_info_lock);
+ old_info_hash = fib_info_hash;
+ old_laddrhash = fib_info_laddrhash;
fib_hash_size = new_size;
for (i = 0; i < old_size; i++) {
@@ -636,6 +639,10 @@ static void fib_hash_move(struct hlist_head *new_info_hash,
fib_info_laddrhash = new_laddrhash;
write_unlock(&fib_info_lock);
+
+ bytes = old_size * sizeof(struct hlist_head *);
+ fib_hash_free(old_info_hash, bytes);
+ fib_hash_free(old_laddrhash, bytes);
}
struct fib_info *