]> err.no Git - linux-2.6/commitdiff
[NETFILTER]: Fix memory leak in ipt_recent
authorJesper Juhl <jesper.juhl@gmail.com>
Fri, 19 May 2006 09:15:13 +0000 (02:15 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 19 May 2006 09:15:13 +0000 (02:15 -0700)
The Coverity checker spotted that we may leak 'hold' in
net/ipv4/netfilter/ipt_recent.c::checkentry() when the following
is true:
  if (!curr_table->status_proc) {
    ...
    if(!curr_table) {
    ...
      return 0;  <-- here we leak.
Simply moving an existing vfree(hold); up a bit avoids the possible leak.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/netfilter/ipt_recent.c

index 1438432857021b1ebd09486362cd9243f5f9554e..b847ee409efbb7146987f526998ccb8ea51422fe 100644 (file)
@@ -821,6 +821,7 @@ checkentry(const char *tablename,
        /* Create our proc 'status' entry. */
        curr_table->status_proc = create_proc_entry(curr_table->name, ip_list_perms, proc_net_ipt_recent);
        if (!curr_table->status_proc) {
+               vfree(hold);
                printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for /proc entry.\n");
                /* Destroy the created table */
                spin_lock_bh(&recent_lock);
@@ -845,7 +846,6 @@ checkentry(const char *tablename,
                spin_unlock_bh(&recent_lock);
                vfree(curr_table->time_info);
                vfree(curr_table->hash_table);
-               vfree(hold);
                vfree(curr_table->table);
                vfree(curr_table);
                return 0;