]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[NETPOLL]: Fix a leak-n-bug in netpoll_cleanup()
authorSatyam Sharma <ssatyam@cse.iitk.ac.in>
Mon, 9 Jul 2007 22:22:23 +0000 (15:22 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 11 Jul 2007 05:19:02 +0000 (22:19 -0700)
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>
net/core/netpoll.c

index 4b06d1936375b9789b3ce538933edd2dc1701fba..de1b26aa5720f011616413d87d852f94d46f9c52 100644 (file)
@@ -783,7 +783,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;
                        }
                }