Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcp: must free metrics at net dismantle

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>

authored by

Eric Dumazet and committed by
David S. Miller
36471012 f5addb91

+12
+12
net/ipv4/tcp_metrics.c
··· 731 731 732 732 static void __net_exit tcp_net_metrics_exit(struct net *net) 733 733 { 734 + unsigned int i; 735 + 736 + for (i = 0; i < (1U << net->ipv4.tcp_metrics_hash_log) ; i++) { 737 + struct tcp_metrics_block *tm, *next; 738 + 739 + tm = rcu_dereference_protected(net->ipv4.tcp_metrics_hash[i].chain, 1); 740 + while (tm) { 741 + next = rcu_dereference_protected(tm->tcpm_next, 1); 742 + kfree(tm); 743 + tm = next; 744 + } 745 + } 734 746 kfree(net->ipv4.tcp_metrics_hash); 735 747 } 736 748