Patchwork smsc911x: fix BUG if module is removed while interface is up

login
register
mail settings
Submitter Steve Glendinning
Date Dec. 19, 2008, 2:03 p.m.
Message ID <1229695418-27275-1-git-send-email-steve.glendinning@smsc.com>
Download mbox | patch
Permalink /patch/14827/
State Accepted
Delegated to: David Miller
Headers show

Comments

Steve Glendinning - Dec. 19, 2008, 2:03 p.m.
If the module is removed while its interface is up, smsc911x_stop is not
called until after smsc911x_drv_remove has disposed of phy_dev.  This
patch changes the stop method to handle this situation.

This is a different problem to the one reported by dfoley@telus.net.

Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>
---
 drivers/net/smsc911x.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
David Miller - Dec. 26, 2008, 12:41 a.m.
From: Steve Glendinning <steve.glendinning@smsc.com>
Date: Fri, 19 Dec 2008 14:03:38 +0000

> If the module is removed while its interface is up, smsc911x_stop is not
> called until after smsc911x_drv_remove has disposed of phy_dev.  This
> patch changes the stop method to handle this situation.
> 
> This is a different problem to the one reported by dfoley@telus.net.
> 
> Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>

Applied.
--
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/smsc911x.c b/drivers/net/smsc911x.c
index fa28542..552e97f 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -1267,8 +1267,6 @@  static int smsc911x_stop(struct net_device *dev)
 	struct smsc911x_data *pdata = netdev_priv(dev);
 	unsigned int temp;
 
-	BUG_ON(!pdata->phy_dev);
-
 	/* Disable all device interrupts */
 	temp = smsc911x_reg_read(pdata, INT_CFG);
 	temp &= ~INT_CFG_IRQ_EN_;
@@ -1283,7 +1281,8 @@  static int smsc911x_stop(struct net_device *dev)
 	smsc911x_tx_update_txcounters(dev);
 
 	/* Bring the PHY down */
-	phy_stop(pdata->phy_dev);
+	if (pdata->phy_dev)
+		phy_stop(pdata->phy_dev);
 
 	SMSC_TRACE(IFDOWN, "Interface stopped");
 	return 0;