diff options
author | Srinivas Kandagatla <srinivas.kandagatla@st.com> | 2012-08-30 01:49:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-31 16:11:16 -0400 |
commit | a5cf5ce92ecefcbeb3265e6f894905ab3ed5c4c2 (patch) | |
tree | 0118e009990a296335492414155b11b736bf9619 | |
parent | fcb118491bc8bc16c4eeb8142366bcbe17fe615d (diff) |
net:stmmac: Add check if mdiobus is registered in stmmac_mdio_unregister
This patch adds a basic check in stmmac_mdio_unregister to see if mdio
bus registeration for this driver was actually sucessfull or not.
Use case here is, if BSP considers using mdio-gpio bus along with stmmac
driver by passing mdio_bus_data as NULL in platform data.
Call to stmmac_mdio_register with mdio_bus_data as NULL returns 0, which
is a considered sucessfull call form stmmac. Then again when we unload
the driver we just call stmmac_mdio_unregister, this is were the actual
problem is stmmac-mdio code dont really know at this instance of calling
that stmmac_mdio_register was actually successful.
So Adding a check in stmmac_mdio_unregister is always safe.
Without this patch stmmac driver calls stmmac_mdio_register from
stmmac_release which Segfaults as mii bus was never registered at the
first point.
Originally the this bug was found when unloading an stmmac driver
instance which uses mdio-gpio for smi access.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index ade108232048..e1f3d04a8c90 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | |||
@@ -258,6 +258,9 @@ int stmmac_mdio_unregister(struct net_device *ndev) | |||
258 | { | 258 | { |
259 | struct stmmac_priv *priv = netdev_priv(ndev); | 259 | struct stmmac_priv *priv = netdev_priv(ndev); |
260 | 260 | ||
261 | if (!priv->mii) | ||
262 | return 0; | ||
263 | |||
261 | mdiobus_unregister(priv->mii); | 264 | mdiobus_unregister(priv->mii); |
262 | priv->mii->priv = NULL; | 265 | priv->mii->priv = NULL; |
263 | mdiobus_free(priv->mii); | 266 | mdiobus_free(priv->mii); |