Skip to content

Commit

Permalink
tcp: must free metrics at net dismantle
Browse files Browse the repository at this point in the history
We currently leak all tcp metrics at struct net dismantle time.

tcp_net_metrics_exit() frees the hash table, we must first
iterate it to free all metrics.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Aug 9, 2012
1 parent f5addb9 commit 3647101
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions net/ipv4/tcp_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,18 @@ static int __net_init tcp_net_metrics_init(struct net *net)

static void __net_exit tcp_net_metrics_exit(struct net *net)
{
unsigned int i;

for (i = 0; i < (1U << net->ipv4.tcp_metrics_hash_log) ; i++) {
struct tcp_metrics_block *tm, *next;

tm = rcu_dereference_protected(net->ipv4.tcp_metrics_hash[i].chain, 1);
while (tm) {
next = rcu_dereference_protected(tm->tcpm_next, 1);
kfree(tm);
tm = next;
}
}
kfree(net->ipv4.tcp_metrics_hash);
}

Expand Down

0 comments on commit 3647101

Please sign in to comment.