Patchwork be2net: Fix a potential crash during shutdown.

login
register
mail settings
Submitter Ajit Khaparde
Date April 6, 2011, 3:53 p.m.
Message ID <20110406155313.GA2246@akhaparde-VBox>
Download mbox | patch
Permalink /patch/90036/
State Accepted
Delegated to: David Miller
Headers show

Comments

Ajit Khaparde - April 6, 2011, 3:53 p.m.
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>
---
 drivers/net/benet/be_main.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
David Miller - April 6, 2011, 7:40 p.m.
From: Ajit Khaparde <ajit.khaparde@emulex.com>
Date: Wed, 6 Apr 2011 10:53:13 -0500

> 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>

Applied to net-2.6, thank you.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index a71163f..6e8e211 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -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);