bonding: Fix netconsole to not deadlock on rmmod
authorNeil Horman <nhorman@tuxdriver.com>
Wed, 13 Oct 2010 16:01:52 +0000 (16:01 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Oct 2010 15:32:08 +0000 (08:32 -0700)
Netconsole calls netpoll_cleanup on receipt of a NETDEVICE_UNREGISTER event.
The notifier subsystem calls these event handlers with rtnl_lock held, which
netpoll_cleanup also takes, resulting in deadlock.  Fix this by calling the
__netpoll_cleanup interior function instead, and fixing up the additional
pointers.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netconsole.c

index ca142c4..94255f0 100644 (file)
@@ -678,7 +678,14 @@ static int netconsole_netdev_event(struct notifier_block *this,
                                strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ);
                                break;
                        case NETDEV_UNREGISTER:
-                               netpoll_cleanup(&nt->np);
+                               /*
+                                * rtnl_lock already held
+                                */
+                               if (nt->np.dev) {
+                                       __netpoll_cleanup(&nt->np);
+                                       dev_put(nt->np.dev);
+                                       nt->np.dev = NULL;
+                               }
                                /* Fall through */
                        case NETDEV_GOING_DOWN:
                        case NETDEV_BONDING_DESLAVE: