summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2006-10-27 00:46:50 +0200
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 06:22:32 +0100
commit93ec2c723e3f8a216dde2899aeb85c648672bc6b (patch)
treea70a10812c2340edfce0d1010175535aa344d1c9 /net/core
parentnetpoll: private skb pool (rev3) (diff)
downloadlinux-93ec2c723e3f8a216dde2899aeb85c648672bc6b.tar.xz
linux-93ec2c723e3f8a216dde2899aeb85c648672bc6b.zip
netpoll info leak
After looking harder, Steve noticed that the netpoll beast leaked a little every time it shutdown for a nap. Not a big leak, but a nuisance kind of thing. He took out his refcount duct tape and patched the leak. It was overkill since there was already other locking in that area, but it looked clean and wouldn't attract fleas. Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/netpoll.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 4de62f1f4134..c66df2f45d26 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -658,8 +658,11 @@ int netpoll_setup(struct netpoll *np)
npinfo->tries = MAX_RETRIES;
spin_lock_init(&npinfo->rx_lock);
skb_queue_head_init(&npinfo->arp_tx);
- } else
+ atomic_set(&npinfo->refcnt, 1);
+ } else {
npinfo = ndev->npinfo;
+ atomic_inc(&npinfo->refcnt);
+ }
if (!ndev->poll_controller) {
printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
@@ -766,12 +769,22 @@ void netpoll_cleanup(struct netpoll *np)
if (np->dev) {
npinfo = np->dev->npinfo;
- if (npinfo && npinfo->rx_np == np) {
- spin_lock_irqsave(&npinfo->rx_lock, flags);
- npinfo->rx_np = NULL;
- npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
- spin_unlock_irqrestore(&npinfo->rx_lock, flags);
+ if (npinfo) {
+ if (npinfo->rx_np == np) {
+ spin_lock_irqsave(&npinfo->rx_lock, flags);
+ npinfo->rx_np = NULL;
+ npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
+ spin_unlock_irqrestore(&npinfo->rx_lock, flags);
+ }
+
+ np->dev->npinfo = NULL;
+ if (atomic_dec_and_test(&npinfo->refcnt)) {
+ skb_queue_purge(&npinfo->arp_tx);
+
+ kfree(npinfo);
+ }
}
+
dev_put(np->dev);
}