Commit 18bc89aa authored by Jayachandran C's avatar Jayachandran C Committed by David S. Miller

[EBTABLES]: Clean up vmalloc usage in net/bridge/netfilter/ebtables.c

Make all the vmalloc calls in net/bridge/netfilter/ebtables.c follow
the standard convention.  Remove unnecessary casts, and use '*object'
instead of 'type'.
Signed-off-by: default avatarJayachandran C. <c.jayachandran@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dc6de336
...@@ -831,7 +831,7 @@ static int translate_table(struct ebt_replace *repl, ...@@ -831,7 +831,7 @@ static int translate_table(struct ebt_replace *repl,
return -ENOMEM; return -ENOMEM;
for_each_possible_cpu(i) { for_each_possible_cpu(i) {
newinfo->chainstack[i] = newinfo->chainstack[i] =
vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0])));
if (!newinfo->chainstack[i]) { if (!newinfo->chainstack[i]) {
while (i) while (i)
vfree(newinfo->chainstack[--i]); vfree(newinfo->chainstack[--i]);
...@@ -841,8 +841,7 @@ static int translate_table(struct ebt_replace *repl, ...@@ -841,8 +841,7 @@ static int translate_table(struct ebt_replace *repl,
} }
} }
cl_s = (struct ebt_cl_stack *) cl_s = vmalloc(udc_cnt * sizeof(*cl_s));
vmalloc(udc_cnt * sizeof(struct ebt_cl_stack));
if (!cl_s) if (!cl_s)
return -ENOMEM; return -ENOMEM;
i = 0; /* the i'th udc */ i = 0; /* the i'th udc */
...@@ -944,8 +943,7 @@ static int do_replace(void __user *user, unsigned int len) ...@@ -944,8 +943,7 @@ static int do_replace(void __user *user, unsigned int len)
countersize = COUNTER_OFFSET(tmp.nentries) * countersize = COUNTER_OFFSET(tmp.nentries) *
(highest_possible_processor_id()+1); (highest_possible_processor_id()+1);
newinfo = (struct ebt_table_info *) newinfo = vmalloc(sizeof(*newinfo) + countersize);
vmalloc(sizeof(struct ebt_table_info) + countersize);
if (!newinfo) if (!newinfo)
return -ENOMEM; return -ENOMEM;
...@@ -967,8 +965,7 @@ static int do_replace(void __user *user, unsigned int len) ...@@ -967,8 +965,7 @@ static int do_replace(void __user *user, unsigned int len)
/* the user wants counters back /* the user wants counters back
the check on the size is done later, when we have the lock */ the check on the size is done later, when we have the lock */
if (tmp.num_counters) { if (tmp.num_counters) {
counterstmp = (struct ebt_counter *) counterstmp = vmalloc(tmp.num_counters * sizeof(*counterstmp));
vmalloc(tmp.num_counters * sizeof(struct ebt_counter));
if (!counterstmp) { if (!counterstmp) {
ret = -ENOMEM; ret = -ENOMEM;
goto free_entries; goto free_entries;
...@@ -1148,8 +1145,7 @@ int ebt_register_table(struct ebt_table *table) ...@@ -1148,8 +1145,7 @@ int ebt_register_table(struct ebt_table *table)
countersize = COUNTER_OFFSET(table->table->nentries) * countersize = COUNTER_OFFSET(table->table->nentries) *
(highest_possible_processor_id()+1); (highest_possible_processor_id()+1);
newinfo = (struct ebt_table_info *) newinfo = vmalloc(sizeof(*newinfo) + countersize);
vmalloc(sizeof(struct ebt_table_info) + countersize);
ret = -ENOMEM; ret = -ENOMEM;
if (!newinfo) if (!newinfo)
return -ENOMEM; return -ENOMEM;
...@@ -1247,8 +1243,7 @@ static int update_counters(void __user *user, unsigned int len) ...@@ -1247,8 +1243,7 @@ static int update_counters(void __user *user, unsigned int len)
if (hlp.num_counters == 0) if (hlp.num_counters == 0)
return -EINVAL; return -EINVAL;
if ( !(tmp = (struct ebt_counter *) if (!(tmp = vmalloc(hlp.num_counters * sizeof(*tmp)))) {
vmalloc(hlp.num_counters * sizeof(struct ebt_counter))) ){
MEMPRINT("Update_counters && nomemory\n"); MEMPRINT("Update_counters && nomemory\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -1377,8 +1372,7 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user, ...@@ -1377,8 +1372,7 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user,
BUGPRINT("Num_counters wrong\n"); BUGPRINT("Num_counters wrong\n");
return -EINVAL; return -EINVAL;
} }
counterstmp = (struct ebt_counter *) counterstmp = vmalloc(nentries * sizeof(*counterstmp));
vmalloc(nentries * sizeof(struct ebt_counter));
if (!counterstmp) { if (!counterstmp) {
MEMPRINT("Couldn't copy counters, out of memory\n"); MEMPRINT("Couldn't copy counters, out of memory\n");
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment