diff options
| author | Jayachandran C <c.jayachandran@gmail.com> | 2006-04-20 03:14:49 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2006-04-20 03:14:49 -0400 |
| commit | 18bc89aa25fbfcf467f4ce67f76c7b9893404cac (patch) | |
| tree | aa11b287484cddd932df71ca18da90d54239da93 | |
| parent | dc6de33674608f978ec29f5c2f7e3af458c06f78 (diff) | |
[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: Jayachandran C. <c.jayachandran@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/bridge/netfilter/ebtables.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 84b9af76f0a2..3a13ed643459 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
| @@ -831,7 +831,7 @@ static int translate_table(struct ebt_replace *repl, | |||
| 831 | return -ENOMEM; | 831 | return -ENOMEM; |
| 832 | for_each_possible_cpu(i) { | 832 | for_each_possible_cpu(i) { |
| 833 | newinfo->chainstack[i] = | 833 | newinfo->chainstack[i] = |
| 834 | vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); | 834 | vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0]))); |
| 835 | if (!newinfo->chainstack[i]) { | 835 | if (!newinfo->chainstack[i]) { |
| 836 | while (i) | 836 | while (i) |
| 837 | vfree(newinfo->chainstack[--i]); | 837 | vfree(newinfo->chainstack[--i]); |
| @@ -841,8 +841,7 @@ static int translate_table(struct ebt_replace *repl, | |||
| 841 | } | 841 | } |
| 842 | } | 842 | } |
| 843 | 843 | ||
| 844 | cl_s = (struct ebt_cl_stack *) | 844 | cl_s = vmalloc(udc_cnt * sizeof(*cl_s)); |
| 845 | vmalloc(udc_cnt * sizeof(struct ebt_cl_stack)); | ||
| 846 | if (!cl_s) | 845 | if (!cl_s) |
| 847 | return -ENOMEM; | 846 | return -ENOMEM; |
| 848 | i = 0; /* the i'th udc */ | 847 | i = 0; /* the i'th udc */ |
| @@ -944,8 +943,7 @@ static int do_replace(void __user *user, unsigned int len) | |||
| 944 | 943 | ||
| 945 | countersize = COUNTER_OFFSET(tmp.nentries) * | 944 | countersize = COUNTER_OFFSET(tmp.nentries) * |
| 946 | (highest_possible_processor_id()+1); | 945 | (highest_possible_processor_id()+1); |
| 947 | newinfo = (struct ebt_table_info *) | 946 | newinfo = vmalloc(sizeof(*newinfo) + countersize); |
| 948 | vmalloc(sizeof(struct ebt_table_info) + countersize); | ||
| 949 | if (!newinfo) | 947 | if (!newinfo) |
| 950 | return -ENOMEM; | 948 | return -ENOMEM; |
| 951 | 949 | ||
| @@ -967,8 +965,7 @@ static int do_replace(void __user *user, unsigned int len) | |||
| 967 | /* the user wants counters back | 965 | /* the user wants counters back |
| 968 | the check on the size is done later, when we have the lock */ | 966 | the check on the size is done later, when we have the lock */ |
| 969 | if (tmp.num_counters) { | 967 | if (tmp.num_counters) { |
| 970 | counterstmp = (struct ebt_counter *) | 968 | counterstmp = vmalloc(tmp.num_counters * sizeof(*counterstmp)); |
| 971 | vmalloc(tmp.num_counters * sizeof(struct ebt_counter)); | ||
| 972 | if (!counterstmp) { | 969 | if (!counterstmp) { |
| 973 | ret = -ENOMEM; | 970 | ret = -ENOMEM; |
| 974 | goto free_entries; | 971 | goto free_entries; |
| @@ -1148,8 +1145,7 @@ int ebt_register_table(struct ebt_table *table) | |||
| 1148 | 1145 | ||
| 1149 | countersize = COUNTER_OFFSET(table->table->nentries) * | 1146 | countersize = COUNTER_OFFSET(table->table->nentries) * |
| 1150 | (highest_possible_processor_id()+1); | 1147 | (highest_possible_processor_id()+1); |
| 1151 | newinfo = (struct ebt_table_info *) | 1148 | newinfo = vmalloc(sizeof(*newinfo) + countersize); |
| 1152 | vmalloc(sizeof(struct ebt_table_info) + countersize); | ||
| 1153 | ret = -ENOMEM; | 1149 | ret = -ENOMEM; |
| 1154 | if (!newinfo) | 1150 | if (!newinfo) |
| 1155 | return -ENOMEM; | 1151 | return -ENOMEM; |
| @@ -1247,8 +1243,7 @@ static int update_counters(void __user *user, unsigned int len) | |||
| 1247 | if (hlp.num_counters == 0) | 1243 | if (hlp.num_counters == 0) |
| 1248 | return -EINVAL; | 1244 | return -EINVAL; |
| 1249 | 1245 | ||
| 1250 | if ( !(tmp = (struct ebt_counter *) | 1246 | if (!(tmp = vmalloc(hlp.num_counters * sizeof(*tmp)))) { |
| 1251 | vmalloc(hlp.num_counters * sizeof(struct ebt_counter))) ){ | ||
| 1252 | MEMPRINT("Update_counters && nomemory\n"); | 1247 | MEMPRINT("Update_counters && nomemory\n"); |
| 1253 | return -ENOMEM; | 1248 | return -ENOMEM; |
| 1254 | } | 1249 | } |
| @@ -1377,8 +1372,7 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user, | |||
| 1377 | BUGPRINT("Num_counters wrong\n"); | 1372 | BUGPRINT("Num_counters wrong\n"); |
| 1378 | return -EINVAL; | 1373 | return -EINVAL; |
| 1379 | } | 1374 | } |
| 1380 | counterstmp = (struct ebt_counter *) | 1375 | counterstmp = vmalloc(nentries * sizeof(*counterstmp)); |
| 1381 | vmalloc(nentries * sizeof(struct ebt_counter)); | ||
| 1382 | if (!counterstmp) { | 1376 | if (!counterstmp) { |
| 1383 | MEMPRINT("Couldn't copy counters, out of memory\n"); | 1377 | MEMPRINT("Couldn't copy counters, out of memory\n"); |
| 1384 | return -ENOMEM; | 1378 | return -ENOMEM; |
