]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[PATCH] Netpoll leak
authorSatyam Sharma <ssatyam@cse.iitk.ac.in>
Wed, 18 Jul 2007 09:54:19 +0000 (02:54 -0700)
committerWilly Tarreau <w@1wt.eu>
Sat, 25 Aug 2007 15:24:00 +0000 (17:24 +0200)
[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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/core/netpoll.c

index 522e44173e56fb496994714bbd65e53959368e87..3431d485a98a99162d8de16bfcc4484a93fbe7b1 100644 (file)
@@ -776,7 +776,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);
@@ -784,6 +783,7 @@ void netpoll_cleanup(struct netpoll *np)
                                flush_scheduled_work();
 
                                kfree(npinfo);
+                               np->dev->npinfo = NULL;
                        }
                }