Skip to content

Commit

Permalink
[EBTABLES]: vfree() checking cleanups
Browse files Browse the repository at this point in the history
From: jlamanna@gmail.com

ebtables.c vfree() checking cleanups.

Signed-off by: James Lamanna <jlamanna@gmail.com>
Signed-off-by: Domen Puncer <domen@coderock.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
James Lamanna authored and David S. Miller committed Jun 23, 2005
1 parent 285b3af commit 68d3187
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions net/bridge/netfilter/ebtables.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,7 @@ static int translate_table(struct ebt_replace *repl,
if (repl->valid_hooks & (1 << i))
if (check_chainloops(newinfo->hook_entry[i],
cl_s, udc_cnt, i, newinfo->entries)) {
if (cl_s)
vfree(cl_s);
vfree(cl_s);
return -EINVAL;
}

Expand All @@ -883,8 +882,7 @@ static int translate_table(struct ebt_replace *repl,
EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
ebt_cleanup_entry, &i);
}
if (cl_s)
vfree(cl_s);
vfree(cl_s);
return ret;
}

Expand Down Expand Up @@ -1030,8 +1028,7 @@ static int do_replace(void __user *user, unsigned int len)
}
vfree(table);

if (counterstmp)
vfree(counterstmp);
vfree(counterstmp);
return ret;

free_unlock:
Expand All @@ -1040,20 +1037,17 @@ static int do_replace(void __user *user, unsigned int len)
EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
ebt_cleanup_entry, NULL);
free_counterstmp:
if (counterstmp)
vfree(counterstmp);
vfree(counterstmp);
/* can be initialized in translate_table() */
if (newinfo->chainstack) {
for (i = 0; i < num_possible_cpus(); i++)
vfree(newinfo->chainstack[i]);
vfree(newinfo->chainstack);
}
free_entries:
if (newinfo->entries)
vfree(newinfo->entries);
vfree(newinfo->entries);
free_newinfo:
if (newinfo)
vfree(newinfo);
vfree(newinfo);
return ret;
}

Expand Down Expand Up @@ -1213,8 +1207,7 @@ void ebt_unregister_table(struct ebt_table *table)
down(&ebt_mutex);
LIST_DELETE(&ebt_tables, table);
up(&ebt_mutex);
if (table->private->entries)
vfree(table->private->entries);
vfree(table->private->entries);
if (table->private->chainstack) {
for (i = 0; i < num_possible_cpus(); i++)
vfree(table->private->chainstack[i]);
Expand Down

0 comments on commit 68d3187

Please sign in to comment.