netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6]: Fix device leaks in mirred action
@ 2004-11-04  6:30 Patrick McHardy
  2004-11-04 13:53 ` jamal
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick McHardy @ 2004-11-04  6:30 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, jamal

[-- Attachment #1: Type: text/plain, Size: 206 bytes --]

When a mirred action is created it takes two references to the
device (dev_get_by_index + dev_hold), but only drops one when
it gets destroyed. It also leaks a reference when a mirred action
is replaced.



[-- Attachment #2: x --]
[-- Type: text/plain, Size: 793 bytes --]

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/11/04 07:28:30+01:00 kaber@coreworks.de 
#   [PKT_SCHED]: Fix device leaks in mirred action
#   
#   Signed-off-by: Patrick McHardy <kaber@trash.net>
# 
# net/sched/mirred.c
#   2004/11/04 07:28:24+01:00 kaber@coreworks.de +2 -1
#   [PKT_SCHED]: Fix device leaks in mirred action
#   
#   Signed-off-by: Patrick McHardy <kaber@trash.net>
# 
diff -Nru a/net/sched/mirred.c b/net/sched/mirred.c
--- a/net/sched/mirred.c	2004-11-04 07:28:59 +01:00
+++ b/net/sched/mirred.c	2004-11-04 07:28:59 +01:00
@@ -138,8 +138,9 @@
 		p->eaction = parm->eaction;
 		if (parm->ifindex) {
 			p->ifindex = parm->ifindex;
+			if (ovr)
+				dev_put(p->dev);
 			p->dev = dev;
-			dev_hold(p->dev); 
 		}
 		spin_unlock(&p->lock);
 	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6]: Fix device leaks in mirred action
  2004-11-04  6:30 [PATCH 2.6]: Fix device leaks in mirred action Patrick McHardy
@ 2004-11-04 13:53 ` jamal
  2004-11-04 14:58   ` Patrick McHardy
  0 siblings, 1 reply; 4+ messages in thread
From: jamal @ 2004-11-04 13:53 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: David S. Miller, netdev

On Thu, 2004-11-04 at 01:30, Patrick McHardy wrote:
> When a mirred action is created it takes two references to the
> device (dev_get_by_index + dev_hold), but only drops one when
> it gets destroyed. 

Good catch.
The correct fix is to remove the dev_hold(p->dev) call.

> It also leaks a reference when a mirred action
> is replaced.

How? Is this patch supposed to fix that?

cheers,
jamal

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6]: Fix device leaks in mirred action
  2004-11-04 13:53 ` jamal
@ 2004-11-04 14:58   ` Patrick McHardy
  2004-11-04 15:23     ` jamal
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick McHardy @ 2004-11-04 14:58 UTC (permalink / raw)
  To: hadi; +Cc: David S. Miller, netdev

jamal wrote:

>>It also leaks a reference when a mirred action
>>is replaced.
>>    
>>
>
>How? Is this patch supposed to fix that?
>  
>
+                       if (ovr)
+                               dev_put(p->dev);
                        p->dev = dev;

By dropping the reference before replacing it.

Regards
Patrick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6]: Fix device leaks in mirred action
  2004-11-04 14:58   ` Patrick McHardy
@ 2004-11-04 15:23     ` jamal
  0 siblings, 0 replies; 4+ messages in thread
From: jamal @ 2004-11-04 15:23 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: David S. Miller, netdev

On Thu, 2004-11-04 at 09:58, Patrick McHardy wrote:
> jamal wrote:
> 
> >>It also leaks a reference when a mirred action
> >>is replaced.
> >
> >How? Is this patch supposed to fix that?
> >  
> >
> +                       if (ovr)
> +                               dev_put(p->dev);
>                         p->dev = dev;
> 
> By dropping the reference before replacing it.
> 

Ok, makes sense. Thanks Patrick.
Dave please apply the patch in its entirety.

cheers,
jamal

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-04 15:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-04  6:30 [PATCH 2.6]: Fix device leaks in mirred action Patrick McHardy
2004-11-04 13:53 ` jamal
2004-11-04 14:58   ` Patrick McHardy
2004-11-04 15:23     ` jamal

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).