Skip to content

Commit 18bc89a

Browse files
Jayachandran Cdavem330
authored andcommitted
[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>
1 parent dc6de33 commit 18bc89a

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

‎net/bridge/netfilter/ebtables.c‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ static int translate_table(struct ebt_replace *repl,
831831
return -ENOMEM;
832832
for_each_possible_cpu(i) {
833833
newinfo->chainstack[i] =
834-
vmalloc(udc_cnt * sizeof(struct ebt_chainstack));
834+
vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0])));
835835
if (!newinfo->chainstack[i]) {
836836
while (i)
837837
vfree(newinfo->chainstack[--i]);
@@ -841,8 +841,7 @@ static int translate_table(struct ebt_replace *repl,
841841
}
842842
}
843843

844-
cl_s = (struct ebt_cl_stack *)
845-
vmalloc(udc_cnt * sizeof(struct ebt_cl_stack));
844+
cl_s = vmalloc(udc_cnt * sizeof(*cl_s));
846845
if (!cl_s)
847846
return -ENOMEM;
848847
i = 0; /* the i'th udc */
@@ -944,8 +943,7 @@ static int do_replace(void __user *user, unsigned int len)
944943

945944
countersize = COUNTER_OFFSET(tmp.nentries) *
946945
(highest_possible_processor_id()+1);
947-
newinfo = (struct ebt_table_info *)
948-
vmalloc(sizeof(struct ebt_table_info) + countersize);
946+
newinfo = vmalloc(sizeof(*newinfo) + countersize);
949947
if (!newinfo)
950948
return -ENOMEM;
951949

@@ -967,8 +965,7 @@ static int do_replace(void __user *user, unsigned int len)
967965
/* the user wants counters back
968966
the check on the size is done later, when we have the lock */
969967
if (tmp.num_counters) {
970-
counterstmp = (struct ebt_counter *)
971-
vmalloc(tmp.num_counters * sizeof(struct ebt_counter));
968+
counterstmp = vmalloc(tmp.num_counters * sizeof(*counterstmp));
972969
if (!counterstmp) {
973970
ret = -ENOMEM;
974971
goto free_entries;
@@ -1148,8 +1145,7 @@ int ebt_register_table(struct ebt_table *table)
11481145

11491146
countersize = COUNTER_OFFSET(table->table->nentries) *
11501147
(highest_possible_processor_id()+1);
1151-
newinfo = (struct ebt_table_info *)
1152-
vmalloc(sizeof(struct ebt_table_info) + countersize);
1148+
newinfo = vmalloc(sizeof(*newinfo) + countersize);
11531149
ret = -ENOMEM;
11541150
if (!newinfo)
11551151
return -ENOMEM;
@@ -1247,8 +1243,7 @@ static int update_counters(void __user *user, unsigned int len)
12471243
if (hlp.num_counters == 0)
12481244
return -EINVAL;
12491245

1250-
if ( !(tmp = (struct ebt_counter *)
1251-
vmalloc(hlp.num_counters * sizeof(struct ebt_counter))) ){
1246+
if (!(tmp = vmalloc(hlp.num_counters * sizeof(*tmp)))) {
12521247
MEMPRINT("Update_counters && nomemory\n");
12531248
return -ENOMEM;
12541249
}
@@ -1377,8 +1372,7 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user,
13771372
BUGPRINT("Num_counters wrong\n");
13781373
return -EINVAL;
13791374
}
1380-
counterstmp = (struct ebt_counter *)
1381-
vmalloc(nentries * sizeof(struct ebt_counter));
1375+
counterstmp = vmalloc(nentries * sizeof(*counterstmp));
13821376
if (!counterstmp) {
13831377
MEMPRINT("Couldn't copy counters, out of memory\n");
13841378
return -ENOMEM;

0 commit comments

Comments
 (0)