* Re: memory leak in net/sched/ipt.c?
[not found] <Pine.LNX.4.61.0503230011090.4207@kaki.stanford.edu>
@ 2005-03-23 11:30 ` Herbert Xu
2005-03-23 12:40 ` jamal
2005-03-23 18:27 ` Yichen Xie
0 siblings, 2 replies; 11+ messages in thread
From: Herbert Xu @ 2005-03-23 11:30 UTC (permalink / raw)
To: Yichen Xie; +Cc: linux-kernel, netdev, davem, kaber, hadi
Yichen Xie <yxie@cs.stanford.edu> wrote:
> Is the memory block allocated on line 315 leaked every time tcp_ipt_dump
> is called?
It seems to be. This patch should free it.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
BTW, please report networking bugs to netdev@oss.sgi.com.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
===== net/sched/ipt.c 1.14 vs edited =====
--- 1.14/net/sched/ipt.c 2005-02-07 16:39:40 +11:00
+++ edited/net/sched/ipt.c 2005-03-23 22:28:13 +11:00
@@ -284,10 +284,12 @@
tm.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse);
tm.expires = jiffies_to_clock_t(p->tm.expires);
RTA_PUT(skb, TCA_IPT_TM, sizeof (tm), &tm);
+ kfree(t);
return skb->len;
rtattr_failure:
skb_trim(skb, b - skb->data);
+ kfree(t);
return -1;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 11:30 ` memory leak in net/sched/ipt.c? Herbert Xu
@ 2005-03-23 12:40 ` jamal
2005-03-23 12:55 ` Thomas Graf
2005-03-23 18:27 ` Yichen Xie
1 sibling, 1 reply; 11+ messages in thread
From: jamal @ 2005-03-23 12:40 UTC (permalink / raw)
To: Herbert Xu; +Cc: Yichen Xie, linux-kernel, netdev, David S. Miller, kaber
On Wed, 2005-03-23 at 06:30, Herbert Xu wrote:
> Yichen Xie <yxie@cs.stanford.edu> wrote:
> > Is the memory block allocated on line 315 leaked every time tcp_ipt_dump
> > is called?
>
> It seems to be. This patch should free it.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> BTW, please report networking bugs to netdev@oss.sgi.com.
>
Thanks for pointing this out - I _know_ its in the kernel list FAQ.
I was sitting beside R Gooch when he added "thou shalt post to netdev".
And of course i am gonna bitch about it every time someone doesnt
post to netdev;->
Just a small correction to patchlet:
The second kfree should check for existence of t.
cheers,
jamal
> Thanks,
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 12:40 ` jamal
@ 2005-03-23 12:55 ` Thomas Graf
2005-03-23 13:11 ` jamal
0 siblings, 1 reply; 11+ messages in thread
From: Thomas Graf @ 2005-03-23 12:55 UTC (permalink / raw)
To: jamal; +Cc: Herbert Xu, Yichen Xie, linux-kernel, netdev, David S. Miller,
kaber
* jamal <1111581618.1088.72.camel@jzny.localdomain> 2005-03-23 07:40
> On Wed, 2005-03-23 at 06:30, Herbert Xu wrote:
> > Yichen Xie <yxie@cs.stanford.edu> wrote:
> > > Is the memory block allocated on line 315 leaked every time tcp_ipt_dump
> > > is called?
> >
> > It seems to be. This patch should free it.
> >
> > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> Just a small correction to patchlet:
> The second kfree should check for existence of t.
t is either valid or NULL so it's not a problem, unless you want
to create janitor work of course. ;->
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 12:55 ` Thomas Graf
@ 2005-03-23 13:11 ` jamal
2005-03-23 13:23 ` Thomas Graf
2005-03-23 13:40 ` Jan Engelhardt
0 siblings, 2 replies; 11+ messages in thread
From: jamal @ 2005-03-23 13:11 UTC (permalink / raw)
To: Thomas Graf
Cc: Herbert Xu, Yichen Xie, linux-kernel, netdev, David S. Miller,
kaber
On Wed, 2005-03-23 at 07:55, Thomas Graf wrote:
> * jamal <1111581618.1088.72.camel@jzny.localdomain> 2005-03-23 07:40
> > Just a small correction to patchlet:
> > The second kfree should check for existence of t.
>
> t is either valid or NULL so it's not a problem, unless you want
> to create janitor work of course. ;->
if t is null you still goto rtattr_failure
I have seen people put little comments of "kfree will work if you
pass it NULL" - are you saying such assumptions exist all over
net/sched? didnt understand the janitor part.
cheers,
jamal
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 13:11 ` jamal
@ 2005-03-23 13:23 ` Thomas Graf
2005-03-23 13:32 ` jamal
2005-03-23 13:40 ` Jan Engelhardt
1 sibling, 1 reply; 11+ messages in thread
From: Thomas Graf @ 2005-03-23 13:23 UTC (permalink / raw)
To: jamal; +Cc: Herbert Xu, Yichen Xie, linux-kernel, netdev, David S. Miller,
kaber
* jamal <1111583497.1089.92.camel@jzny.localdomain> 2005-03-23 08:11
> On Wed, 2005-03-23 at 07:55, Thomas Graf wrote:
> > * jamal <1111581618.1088.72.camel@jzny.localdomain> 2005-03-23 07:40
>
> > > Just a small correction to patchlet:
> > > The second kfree should check for existence of t.
> >
> > t is either valid or NULL so it's not a problem, unless you want
> > to create janitor work of course. ;->
>
> if t is null you still goto rtattr_failure
> I have seen people put little comments of "kfree will work if you
> pass it NULL" - are you saying such assumptions exist all over
> net/sched?
kfree simply does nothing if it is given a null pointer so that
goto rtattr_failure for t == NULL is handled just fine without
a check. I will never get used to this behaviour and policy as
well though, it somewhat makes code less readable.
> didnt understand the janitor part.
It will probably be removed again by one of the regular 'remove
unnecessary pre kfree checks' patchsets.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 13:23 ` Thomas Graf
@ 2005-03-23 13:32 ` jamal
0 siblings, 0 replies; 11+ messages in thread
From: jamal @ 2005-03-23 13:32 UTC (permalink / raw)
To: Thomas Graf
Cc: Herbert Xu, Yichen Xie, linux-kernel, netdev, David S. Miller,
kaber
On Wed, 2005-03-23 at 08:23, Thomas Graf wrote:
>
> kfree simply does nothing if it is given a null pointer so that
> goto rtattr_failure for t == NULL is handled just fine without
> a check. I will never get used to this behaviour and policy as
> well though, it somewhat makes code less readable.
>
I cant get used to it either; actually i dont think i would be able
to stop my fingers ;->
> > didnt understand the janitor part.
>
> It will probably be removed again by one of the regular 'remove
> unnecessary pre kfree checks' patchsets.
>
Yes, already Jan Engelhardt <jengelh@linux01.gwdg.de> has made that
point - although he did not post to netdev!! ;->
So ignore my comment Herbert
cheers,
jamal
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 13:11 ` jamal
2005-03-23 13:23 ` Thomas Graf
@ 2005-03-23 13:40 ` Jan Engelhardt
2005-03-23 14:05 ` jamal
1 sibling, 1 reply; 11+ messages in thread
From: Jan Engelhardt @ 2005-03-23 13:40 UTC (permalink / raw)
To: jamal; +Cc: linux-kernel, netdev
>I have seen people put little comments of "kfree will work if you
>pass it NULL" - are you saying such assumptions exist all over
>net/sched?
Not only net/sched. The C standard requires that free(NULL) works.
Jan Engelhardt
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 13:40 ` Jan Engelhardt
@ 2005-03-23 14:05 ` jamal
2005-03-23 14:12 ` jamal
0 siblings, 1 reply; 11+ messages in thread
From: jamal @ 2005-03-23 14:05 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: linux-kernel, netdev
On Wed, 2005-03-23 at 08:40, Jan Engelhardt wrote:
> >I have seen people put little comments of "kfree will work if you
> >pass it NULL" - are you saying such assumptions exist all over
> >net/sched?
>
> Not only net/sched. The C standard requires that free(NULL) works.
Thanks for clarifying this.
cheers,
jamal
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 14:05 ` jamal
@ 2005-03-23 14:12 ` jamal
0 siblings, 0 replies; 11+ messages in thread
From: jamal @ 2005-03-23 14:12 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: linux-kernel, netdev
Actually its well documented even on the man pages - so should have not
even have bothered discussing it;-> Should get new brand of coffee.
Apologies for unecessarily abused electrons - which means dont
respond ;->
cheers,
jamal
On Wed, 2005-03-23 at 09:05, jamal wrote:
> On Wed, 2005-03-23 at 08:40, Jan Engelhardt wrote:
> > >I have seen people put little comments of "kfree will work if you
> > >pass it NULL" - are you saying such assumptions exist all over
> > >net/sched?
> >
> > Not only net/sched. The C standard requires that free(NULL) works.
>
> Thanks for clarifying this.
>
> cheers,
> jamal
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: memory leak in net/sched/ipt.c?
2005-03-23 11:30 ` memory leak in net/sched/ipt.c? Herbert Xu
2005-03-23 12:40 ` jamal
@ 2005-03-23 18:27 ` Yichen Xie
2005-03-23 20:37 ` Herbert Xu
1 sibling, 1 reply; 11+ messages in thread
From: Yichen Xie @ 2005-03-23 18:27 UTC (permalink / raw)
To: 'Herbert Xu'; +Cc: linux-kernel, netdev, davem, kaber, hadi
Thanks for confirming. Are you guys interested in this kind of leaks? I have
a list of about a hundred generated by our tool. -yichen
> -----Original Message-----
> From: Herbert Xu [mailto:herbert@gondor.apana.org.au]
> Sent: Wednesday, March 23, 2005 3:31 AM
> To: Yichen Xie
> Cc: linux-kernel@vger.kernel.org; netdev@oss.sgi.com;
> davem@davemloft.net; kaber@trash.net; hadi@cyberus.ca
> Subject: Re: memory leak in net/sched/ipt.c?
>
> Yichen Xie <yxie@cs.stanford.edu> wrote:
> > Is the memory block allocated on line 315 leaked every time
> > tcp_ipt_dump is called?
>
> It seems to be. This patch should free it.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> BTW, please report networking bugs to netdev@oss.sgi.com.
>
> Thanks,
> --
> Visit Openswan at http://www.openswan.org/
> Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
> --
> ===== net/sched/ipt.c 1.14 vs edited =====
> --- 1.14/net/sched/ipt.c 2005-02-07 16:39:40 +11:00
> +++ edited/net/sched/ipt.c 2005-03-23 22:28:13 +11:00
> @@ -284,10 +284,12 @@
> tm.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse);
> tm.expires = jiffies_to_clock_t(p->tm.expires);
> RTA_PUT(skb, TCA_IPT_TM, sizeof (tm), &tm);
> + kfree(t);
> return skb->len;
>
> rtattr_failure:
> skb_trim(skb, b - skb->data);
> + kfree(t);
> return -1;
> }
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: memory leak in net/sched/ipt.c?
2005-03-23 18:27 ` Yichen Xie
@ 2005-03-23 20:37 ` Herbert Xu
0 siblings, 0 replies; 11+ messages in thread
From: Herbert Xu @ 2005-03-23 20:37 UTC (permalink / raw)
To: Yichen Xie; +Cc: linux-kernel, netdev, davem, kaber, hadi
On Wed, Mar 23, 2005 at 10:27:32AM -0800, Yichen Xie wrote:
> Thanks for confirming. Are you guys interested in this kind of leaks? I have
> a list of about a hundred generated by our tool. -yichen
Certainly. Please post all the networking leaks to netdev@oss.sgi.com.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-03-23 20:37 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Pine.LNX.4.61.0503230011090.4207@kaki.stanford.edu>
2005-03-23 11:30 ` memory leak in net/sched/ipt.c? Herbert Xu
2005-03-23 12:40 ` jamal
2005-03-23 12:55 ` Thomas Graf
2005-03-23 13:11 ` jamal
2005-03-23 13:23 ` Thomas Graf
2005-03-23 13:32 ` jamal
2005-03-23 13:40 ` Jan Engelhardt
2005-03-23 14:05 ` jamal
2005-03-23 14:12 ` jamal
2005-03-23 18:27 ` Yichen Xie
2005-03-23 20:37 ` Herbert Xu
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).