netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -rc7 1/1] netpoll: Fix a leak-n-bug in netpoll_cleanup()
@ 2007-07-04 11:06 Satyam Sharma
  2007-07-09 22:22 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Satyam Sharma @ 2007-07-04 11:06 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Satyam Sharma, Netdev, Andrew Morton, David Miller

From: Satyam Sharma <ssatyam@cse.iitk.ac.in>

[1/1] netpoll: Fix a leak-n-bug in netpoll_cleanup()

93ec2c723e3f8a216dde2899aeb85c648672bc6b applied excessive duct tape to
the netpoll beast's netpoll_cleanup(), thus substituting one leak with
another, and opening up a little buglet :-)

net_device->npinfo (netpoll_info) is a shared and refcounted object and
cannot simply be set NULL the first time netpoll_cleanup() is called.
Otherwise, further netpoll_cleanup()'s see np->dev->npinfo == NULL and
become no-ops, thus leaking. And it's a bug too: the first call to
netpoll_cleanup() would thus (annoyingly) "disable" other (still alive)
netpolls too. Maybe nobody noticed this because netconsole (only user
of netpoll) never supported multiple netpoll objects earlier.

This is a trivial and obvious one-line fixlet.

Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in>

[ Andrew, this is diffed against 2.6.22-rc7 but applies successfully to
the 2.6.22-rc6-mm1 tree also. ]

---

 net/core/netpoll.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff -ruNp a/net/core/netpoll.c b/net/core/netpoll.c
--- a/net/core/netpoll.c	2007-07-02 22:11:21.000000000 +0530
+++ b/net/core/netpoll.c	2007-07-03 16:28:10.000000000 +0530
@@ -782,7 +782,6 @@ void netpoll_cleanup(struct netpoll *np)
 				spin_unlock_irqrestore(&npinfo->rx_lock, flags);
 			}
 
-			np->dev->npinfo = NULL;
 			if (atomic_dec_and_test(&npinfo->refcnt)) {
 				skb_queue_purge(&npinfo->arp_tx);
 				skb_queue_purge(&npinfo->txq);
@@ -796,6 +795,7 @@ void netpoll_cleanup(struct netpoll *np)
 					kfree_skb(skb);
 				}
 				kfree(npinfo);
+				np->dev->npinfo = NULL;
 			}
 		}
 

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

* Re: [PATCH -rc7 1/1] netpoll: Fix a leak-n-bug in netpoll_cleanup()
  2007-07-04 11:06 [PATCH -rc7 1/1] netpoll: Fix a leak-n-bug in netpoll_cleanup() Satyam Sharma
@ 2007-07-09 22:22 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-07-09 22:22 UTC (permalink / raw)
  To: ssatyam; +Cc: linux-kernel, netdev, akpm

From: Satyam Sharma <ssatyam@cse.iitk.ac.in>
Date: Wed, 04 Jul 2007 16:36:41 +0530

> From: Satyam Sharma <ssatyam@cse.iitk.ac.in>
> 
> [1/1] netpoll: Fix a leak-n-bug in netpoll_cleanup()
> 
> 93ec2c723e3f8a216dde2899aeb85c648672bc6b applied excessive duct tape to
> the netpoll beast's netpoll_cleanup(), thus substituting one leak with
> another, and opening up a little buglet :-)
> 
> net_device->npinfo (netpoll_info) is a shared and refcounted object and
> cannot simply be set NULL the first time netpoll_cleanup() is called.
> Otherwise, further netpoll_cleanup()'s see np->dev->npinfo == NULL and
> become no-ops, thus leaking. And it's a bug too: the first call to
> netpoll_cleanup() would thus (annoyingly) "disable" other (still alive)
> netpolls too. Maybe nobody noticed this because netconsole (only user
> of netpoll) never supported multiple netpoll objects earlier.
> 
> This is a trivial and obvious one-line fixlet.
> 
> Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in>

Applied to net-2.6.23, I'll forward this on to -stable too.

Thanks.

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

end of thread, other threads:[~2007-07-10  3:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-04 11:06 [PATCH -rc7 1/1] netpoll: Fix a leak-n-bug in netpoll_cleanup() Satyam Sharma
2007-07-09 22:22 ` David Miller

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