* [RESEND][PATCH] ebtables: clean up vmalloc usage in net/bridge/netfilter/ebtables.c
@ 2006-04-19 6:50 Jayachandran C
2006-04-19 22:41 ` David S. Miller
0 siblings, 1 reply; 6+ messages in thread
From: Jayachandran C @ 2006-04-19 6:50 UTC (permalink / raw)
To: bridge, bdschuym; +Cc: netdev, akpm
Second try, added netdev to the cc: list this time.
This cleans up other usages of of vmalloc in ebtables.c. The
changes are similar to the cleanup done in
ebtables-fix-allocation-in-net-bridge-netfilter-ebtablesc.patch
Patch Description:
This patch makes 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 at gmail.com>
---
net/bridge/netfilter/ebtables.c | 20 +++++++-------------
1 files changed, 7 insertions(+), 13 deletions(-)
diff -ur linux-2.6.16-rc6.clean/net/bridge/netfilter/ebtables.c linux-2.6.16-rc6/net/bridge/netfilter/ebtables.c
--- linux-2.6.16-rc6.clean/net/bridge/netfilter/ebtables.c 2006-04-14 14:00:28.000000000 +0530
+++ linux-2.6.16-rc6/net/bridge/netfilter/ebtables.c 2006-04-14 14:22:36.000000000 +0530
@@ -830,7 +830,7 @@
return -ENOMEM;
for_each_cpu(i) {
newinfo->chainstack[i] =
- vmalloc(udc_cnt * sizeof(struct ebt_chainstack));
+ vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0])));
if (!newinfo->chainstack[i]) {
while (i)
vfree(newinfo->chainstack[--i]);
@@ -840,8 +840,7 @@
}
}
- cl_s = (struct ebt_cl_stack *)
- vmalloc(udc_cnt * sizeof(struct ebt_cl_stack));
+ cl_s = vmalloc(udc_cnt * sizeof(*cl_s));
if (!cl_s)
return -ENOMEM;
i = 0; /* the i'th udc */
@@ -943,8 +942,7 @@
countersize = COUNTER_OFFSET(tmp.nentries) *
(highest_possible_processor_id()+1);
- newinfo = (struct ebt_table_info *)
- vmalloc(sizeof(struct ebt_table_info) + countersize);
+ newinfo = vmalloc(sizeof(*newinfo) + countersize);
if (!newinfo)
return -ENOMEM;
@@ -966,8 +964,7 @@
/* the user wants counters back
the check on the size is done later, when we have the lock */
if (tmp.num_counters) {
- counterstmp = (struct ebt_counter *)
- vmalloc(tmp.num_counters * sizeof(struct ebt_counter));
+ counterstmp = vmalloc(tmp.num_counters * sizeof(*counterstmp));
if (!counterstmp) {
ret = -ENOMEM;
goto free_entries;
@@ -1147,8 +1144,7 @@
countersize = COUNTER_OFFSET(table->table->nentries) *
(highest_possible_processor_id()+1);
- newinfo = (struct ebt_table_info *)
- vmalloc(sizeof(struct ebt_table_info) + countersize);
+ newinfo = vmalloc(sizeof(*newinfo) + countersize);
ret = -ENOMEM;
if (!newinfo)
return -ENOMEM;
@@ -1246,8 +1242,7 @@
if (hlp.num_counters == 0)
return -EINVAL;
- if ( !(tmp = (struct ebt_counter *)
- vmalloc(hlp.num_counters * sizeof(struct ebt_counter))) ){
+ if ( !(tmp = vmalloc(hlp.num_counters * sizeof(*tmp))) ){
MEMPRINT("Update_counters && nomemory\n");
return -ENOMEM;
}
@@ -1376,8 +1371,7 @@
BUGPRINT("Num_counters wrong\n");
return -EINVAL;
}
- counterstmp = (struct ebt_counter *)
- vmalloc(nentries * sizeof(struct ebt_counter));
+ counterstmp = vmalloc(nentries * sizeof(*counterstmp));
if (!counterstmp) {
MEMPRINT("Couldn't copy counters, out of memory\n");
return -ENOMEM;
----- End forwarded message -----
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND][PATCH] ebtables: clean up vmalloc usage in net/bridge/netfilter/ebtables.c
2006-04-19 6:50 [RESEND][PATCH] ebtables: clean up vmalloc usage in net/bridge/netfilter/ebtables.c Jayachandran C
@ 2006-04-19 22:41 ` David S. Miller
2006-04-19 22:59 ` Andrew Morton
0 siblings, 1 reply; 6+ messages in thread
From: David S. Miller @ 2006-04-19 22:41 UTC (permalink / raw)
To: jchandra; +Cc: bridge, bdschuym, netdev, akpm
An earlier variant of your patch was applied already, included below.
You'll need to submit the newer parts relative to the current tree.
diff-tree 7ad4d2f6901437ba4717a26d395a73ea362d25c6 (from b8282dcf0417bbc8a0786c129fdff9cc768f8f3c)
Author: Jayachandran C <c.jayachandran@gmail.com>
Date: Tue Apr 11 17:25:38 2006 -0700
[BRIDGE] ebtables: fix allocation in net/bridge/netfilter/ebtables.c
Allocate an array of 'struct ebt_chainstack *', the current code allocates
array of 'struct ebt_chainstack'.
akpm: converted to use the
foo = alloc(sizeof(*foo))
form. Which would have prevented this from happening in the first place.
akpm: also removed unneeded typecast.
akpm: what on earth is this code doing anyway? cpu_possible_map can be
sparse..
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>
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 66bd932..84b9af7 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -824,9 +824,9 @@ static int translate_table(struct ebt_re
if (udc_cnt) {
/* this will get free'd in do_replace()/ebt_register_table()
if an error occurs */
- newinfo->chainstack = (struct ebt_chainstack **)
- vmalloc((highest_possible_processor_id()+1)
- * sizeof(struct ebt_chainstack));
+ newinfo->chainstack =
+ vmalloc((highest_possible_processor_id()+1)
+ * sizeof(*(newinfo->chainstack)));
if (!newinfo->chainstack)
return -ENOMEM;
for_each_possible_cpu(i) {
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RESEND][PATCH] ebtables: clean up vmalloc usage in net/bridge/netfilter/ebtables.c
2006-04-19 22:41 ` David S. Miller
@ 2006-04-19 22:59 ` Andrew Morton
2006-04-19 23:03 ` David S. Miller
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2006-04-19 22:59 UTC (permalink / raw)
To: David S. Miller; +Cc: jchandra, bridge, bdschuym, netdev
"David S. Miller" <davem@davemloft.net> wrote:
>
> An earlier variant of your patch was applied already, included below.
> You'll need to submit the newer parts relative to the current tree.
This is a similar-but-different patch. It applies OK.
I reviewed it (mostly - it's somewhat non-trivial to do this) and queued it
up and was planning on sending it to you for post-2.6.17.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND][PATCH] ebtables: clean up vmalloc usage in net/bridge/netfilter/ebtables.c
2006-04-19 22:59 ` Andrew Morton
@ 2006-04-19 23:03 ` David S. Miller
2006-04-19 23:13 ` Andrew Morton
0 siblings, 1 reply; 6+ messages in thread
From: David S. Miller @ 2006-04-19 23:03 UTC (permalink / raw)
To: akpm; +Cc: jchandra, bridge, bdschuym, netdev
From: Andrew Morton <akpm@osdl.org>
Date: Wed, 19 Apr 2006 15:59:25 -0700
> "David S. Miller" <davem@davemloft.net> wrote:
> >
> > An earlier variant of your patch was applied already, included below.
> > You'll need to submit the newer parts relative to the current tree.
>
> This is a similar-but-different patch. It applies OK.
>
> I reviewed it (mostly - it's somewhat non-trivial to do this) and queued it
> up and was planning on sending it to you for post-2.6.17.
It's at least fixing a few bugs, and the parts which are cleanups
undoubtedly should prevent bugs in the future, so I think we
should consider it for 2.6.17 right?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND][PATCH] ebtables: clean up vmalloc usage in net/bridge/netfilter/ebtables.c
2006-04-19 23:03 ` David S. Miller
@ 2006-04-19 23:13 ` Andrew Morton
2006-04-20 7:32 ` Jayachandran C
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2006-04-19 23:13 UTC (permalink / raw)
To: David S. Miller; +Cc: jchandra, bridge, bdschuym, netdev
"David S. Miller" <davem@davemloft.net> wrote:
>
> From: Andrew Morton <akpm@osdl.org>
> Date: Wed, 19 Apr 2006 15:59:25 -0700
>
> > "David S. Miller" <davem@davemloft.net> wrote:
> > >
> > > An earlier variant of your patch was applied already, included below.
> > > You'll need to submit the newer parts relative to the current tree.
> >
> > This is a similar-but-different patch. It applies OK.
> >
> > I reviewed it (mostly - it's somewhat non-trivial to do this) and queued it
> > up and was planning on sending it to you for post-2.6.17.
>
> It's at least fixing a few bugs, and the parts which are cleanups
> undoubtedly should prevent bugs in the future, so I think we
> should consider it for 2.6.17 right?
afaict it's just a cleanup, but whatever - I'll send it over now.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND][PATCH] ebtables: clean up vmalloc usage in net/bridge/netfilter/ebtables.c
2006-04-19 23:13 ` Andrew Morton
@ 2006-04-20 7:32 ` Jayachandran C
0 siblings, 0 replies; 6+ messages in thread
From: Jayachandran C @ 2006-04-20 7:32 UTC (permalink / raw)
To: David S. Miller; +Cc: bridge, bdschuym, netdev, Andrew Morton
On Wed, Apr 19, 2006 at 04:13:24PM -0700, Andrew Morton wrote:
> "David S. Miller" <davem@davemloft.net> wrote:
> >
> > From: Andrew Morton <akpm@osdl.org>
> > Date: Wed, 19 Apr 2006 15:59:25 -0700
> >
> > > "David S. Miller" <davem@davemloft.net> wrote:
> > > >
> > > > An earlier variant of your patch was applied already, included below.
> > > > You'll need to submit the newer parts relative to the current tree.
> > >
> > > This is a similar-but-different patch. It applies OK.
> > >
> > > I reviewed it (mostly - it's somewhat non-trivial to do this) and queued it
> > > up and was planning on sending it to you for post-2.6.17.
> >
> > It's at least fixing a few bugs, and the parts which are cleanups
> > undoubtedly should prevent bugs in the future, so I think we
> > should consider it for 2.6.17 right?
>
> afaict it's just a cleanup, but whatever - I'll send it over now.
The first patch (which is already applied) was a bug fix. This one
is just a clean up, it makes the same clean-up that Andrew did to
the original patch, in other places in the same file.
This is not at all critical, so it can be moved post-2.6.17 without
any problem.
Regards,
JC.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-04-20 7:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-19 6:50 [RESEND][PATCH] ebtables: clean up vmalloc usage in net/bridge/netfilter/ebtables.c Jayachandran C
2006-04-19 22:41 ` David S. Miller
2006-04-19 22:59 ` Andrew Morton
2006-04-19 23:03 ` David S. Miller
2006-04-19 23:13 ` Andrew Morton
2006-04-20 7:32 ` Jayachandran C
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).