Skip to contentSkip to conversation

nf_conntrack: free layer-3 specific protocol tables at cleanup

PATCH In review KOVACS Krisztian 1 participant 1 message Nov 5, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 nf_conntrack: free layer-3 specific protocol tables at cleanup

Hi,

nfsim complained about memory leaks caused by not kfree()-ing the
layer3-specific protocol tables when nf_conntrack is removed. The attached patch tries to add the missing kfree() calls.

Signature · 2 lines
 Regards,
  Krisztian Kovacs

[NETFILTER] Free layer-3 specific protocol tables at cleanup

Although the comment around the allocation code tells us that the layer-3 specific protocol tables will be freed when cleaning up, they aren't. And this makes nfsim complain loudly...

---
commit e7f59b326ea02ed98dfbacd06ed8932efe4e0de3
tree ab6704864b46f9d7e94431495165cfefba1b9316
parent 43659ba2b9e9f9871bb8cad6769c693a3fc629af
author KOVACS Krisztian <[email protected]> Fri, 04 Nov 2005 11:37:25 +0100 committer KOVACS Krisztian <[email protected]> Fri, 04 Nov 2005 11:37:25 +0100

 net/netfilter/nf_conntrack_core.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
net/netfilter/nf_conntrack_core.c +7 -0
index 9a67c79..ea094b2 100644
@@ -1395,6 +1395,13 @@ void nf_conntrack_cleanup(void)
 	kmem_cache_destroy(nf_conntrack_expect_cachep);
 	free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc,
 			    nf_conntrack_htable_size);
+
+	/* free l3proto protocol tables */
+	for (i = 0; i < PF_MAX; i++)
+		if (nf_ct_protos[i]) {
+			kfree(nf_ct_protos[i]);
+			nf_ct_protos[i] = NULL;
+		}
 }
 
 static struct list_head *alloc_hashtable(int size, int *vmalloced)