]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
be2net: Fix a potential crash during shutdown.
authorAjit Khaparde <ajit.khaparde@emulex.com>
Wed, 6 Apr 2011 05:53:13 +0000 (05:53 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Apr 2011 19:40:18 +0000 (12:40 -0700)
adapter could remain uninitialized if probe fails for some reason.
A null pointer access could cause a crash if be_shutdown
is called after that.

Signed-off-by: Ajit Khaparde <ajit.khaparde@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/benet/be_main.c

index a71163f1e34b80eabd12e0e33ba46583b041004b..6e8e211d8afe4dd4cfa286f283bf09a5fa082192 100644 (file)
@@ -3141,12 +3141,14 @@ static int be_resume(struct pci_dev *pdev)
 static void be_shutdown(struct pci_dev *pdev)
 {
        struct be_adapter *adapter = pci_get_drvdata(pdev);
-       struct net_device *netdev =  adapter->netdev;
 
-       if (netif_running(netdev))
+       if (!adapter)
+               return;
+
+       if (netif_running(adapter->netdev))
                cancel_delayed_work_sync(&adapter->work);
 
-       netif_device_detach(netdev);
+       netif_device_detach(adapter->netdev);
 
        be_cmd_reset_function(adapter);