Re: [PATCH] fix mem-leak in netfilter
From: Patrick McHardy
Date: Fri May 12 2006 - 07:32:52 EST
Jesper Juhl wrote:
> On 5/12/06, Patrick McHardy <kaber@xxxxxxxxx> wrote:
>
>> I haven't seen any cleanup patches so far, so I think I'm
>> going to start my nth try at cleaning up this mess.
>> Unfortunately its even immune to Lindent ..
>>
>
> If you get too fed up with it, let me know, and I'll give it a go as well.
Thanks, I'm about half-way through (and about to kill someone),
just started with the biggest pile of crap (the match function)
and already noticed a possible endless loop within the first
couple of lines.
Unfortunately this stuff is so unreadable that I'm not exactly
sure if the loop really won't terminate, an extra pair of eyes
would be appreciated.
diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c
index 1438432..b8850a2 100644
--- a/net/ipv4/netfilter/ipt_recent.c
+++ b/net/ipv4/netfilter/ipt_recent.c
@@ -438,11 +438,15 @@ #endif
(!r_list[hash_table[hash_result]].ttl || r_list[hash_table[hash_result]].ttl == ttl))) {
/* Collision in hash table */
hash_result = (hash_result + 1) % ip_list_hash_size;
+ if (hash_result == orig_hash_result)
+ break;
}
} else {
while(hash_table[hash_result] != -1 && r_list[hash_table[hash_result]].addr != addr) {
/* Collision in hash table */
hash_result = (hash_result + 1) % ip_list_hash_size;
+ if (hash_result == orig_hash_result)
+ break;
}
}