netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Stlinux-devel] [PATCH linux-stm 1/4] net:stmmac: Add check if mdiobus is registered in stmmac_mdio_unregister
@ 2012-08-30 15:49 Srinivas KANDAGATLA
  2012-08-31 20:12 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Srinivas KANDAGATLA @ 2012-08-30 15:49 UTC (permalink / raw)
  To: netdev; +Cc: peppe.cavallaro

From: Srinivas Kandagatla <srinivas.kandagatla@st.com>

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>
---
 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 ade1082..e1f3d04 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)
 {
 	struct stmmac_priv *priv = netdev_priv(ndev);
 
+	if (!priv->mii)
+		return 0;
+
 	mdiobus_unregister(priv->mii);
 	priv->mii->priv = NULL;
 	mdiobus_free(priv->mii);
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Stlinux-devel] [PATCH linux-stm 1/4] net:stmmac: Add check if mdiobus is registered in stmmac_mdio_unregister
  2012-08-30 15:49 [Stlinux-devel] [PATCH linux-stm 1/4] net:stmmac: Add check if mdiobus is registered in stmmac_mdio_unregister Srinivas KANDAGATLA
@ 2012-08-31 20:12 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-08-31 20:12 UTC (permalink / raw)
  To: srinivas.kandagatla; +Cc: netdev, peppe.cavallaro

From: Srinivas KANDAGATLA <srinivas.kandagatla@st.com>
Date: Thu, 30 Aug 2012 16:49:58 +0100

> From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
> 
> 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>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-31 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-30 15:49 [Stlinux-devel] [PATCH linux-stm 1/4] net:stmmac: Add check if mdiobus is registered in stmmac_mdio_unregister Srinivas KANDAGATLA
2012-08-31 20:12 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).