linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: stmmac: Fix error path after register_netdev move
@ 2016-12-28 23:44 Florian Fainelli
       [not found] ` <D6759987A7968C4889FDA6FA91D5CBC801CA3364@PGSMSX103.gar.corp.intel.com>
  2016-12-29 17:08 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Fainelli @ 2016-12-28 23:44 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, pavel, Joao.Pinto, seraphin.bonnaffe,
	alexandre.torgue, manabian, niklas.cassel, johan, boon.leong.ong,
	weifeng.voon, lars.persson, linux-kernel, Giuseppe Cavallaro,
	Alexandre Torgue

Commit 5701659004d6 ("net: stmmac: Fix race between stmmac_drv_probe and
stmmac_open") re-ordered how the MDIO bus registration and the network
device are registered, but missed to unwind the MDIO bus registration in
case we fail to register the network device.

Fixes: 5701659004d6 ("net: stmmac: Fix race between stmmac_drv_probe and stmmac_open")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 5910ea51f8f6..39eb7a65bb9f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3366,12 +3366,19 @@ int stmmac_dvr_probe(struct device *device,
 	}
 
 	ret = register_netdev(ndev);
-	if (ret)
+	if (ret) {
 		netdev_err(priv->dev, "%s: ERROR %i registering the device\n",
 			   __func__, ret);
+		goto error_netdev_register;
+	}
 
 	return ret;
 
+error_netdev_register:
+	if (priv->hw->pcs != STMMAC_PCS_RGMII &&
+	    priv->hw->pcs != STMMAC_PCS_TBI &&
+	    priv->hw->pcs != STMMAC_PCS_RTBI)
+		stmmac_mdio_unregister(ndev);
 error_mdio_register:
 	netif_napi_del(&priv->napi);
 error_hw_init:
-- 
2.9.3

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

* RE: [PATCH net] net: stmmac: Fix error path after register_netdev move
       [not found] ` <D6759987A7968C4889FDA6FA91D5CBC801CA3364@PGSMSX103.gar.corp.intel.com>
@ 2016-12-29  9:36   ` Kweh, Hock Leong
  0 siblings, 0 replies; 3+ messages in thread
From: Kweh, Hock Leong @ 2016-12-29  9:36 UTC (permalink / raw)
  To: Florian Fainelli, David Miller
  Cc: Joao.Pinto, peppe.cavallaro, seraphin.bonnaffe, alexandre.torgue,
	manabian, niklas.cassel, johan, pavel, Ong, Boon Leong, Voon,
	Weifeng, lars.persson, netdev, linux-kernel, Giuseppe Cavallaro,
	Alexandre Torgue

> -----Original Message-----
> From: Florian Fainelli [mailto:f.fainelli@gmail.com]
> Sent: Thursday, December 29, 2016 7:45 AM
> To: netdev@vger.kernel.org
> Cc: Florian Fainelli <f.fainelli@gmail.com>; pavel@ucw.cz;
> Joao.Pinto@synopsys.com; seraphin.bonnaffe@st.com;
> alexandre.torgue@gmail.com; manabian@gmail.com; niklas.cassel@axis.com;
> johan@kernel.org; Ong, Boon Leong <boon.leong.ong@intel.com>; Voon,
> Weifeng <weifeng.voon@intel.com>; lars.persson@axis.com; linux-
> kernel@vger.kernel.org; Giuseppe Cavallaro <peppe.cavallaro@st.com>;
> Alexandre Torgue <alexandre.torgue@st.com>
> Subject: [PATCH net] net: stmmac: Fix error path after register_netdev move
> 
> Commit 5701659004d6 ("net: stmmac: Fix race between stmmac_drv_probe and
> stmmac_open") re-ordered how the MDIO bus registration and the network
> device are registered, but missed to unwind the MDIO bus registration in case
> we fail to register the network device.
> 
> Fixes: 5701659004d6 ("net: stmmac: Fix race between stmmac_drv_probe and
> stmmac_open")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---

Acked-by: Kweh, Hock Leong <hock.leong.kweh@intel.com>



>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 5910ea51f8f6..39eb7a65bb9f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3366,12 +3366,19 @@ int stmmac_dvr_probe(struct device *device,
>  	}
> 
>  	ret = register_netdev(ndev);
> -	if (ret)
> +	if (ret) {
>  		netdev_err(priv->dev, "%s: ERROR %i registering the device\n",
>  			   __func__, ret);
> +		goto error_netdev_register;
> +	}
> 
>  	return ret;
> 
> +error_netdev_register:
> +	if (priv->hw->pcs != STMMAC_PCS_RGMII &&
> +	    priv->hw->pcs != STMMAC_PCS_TBI &&
> +	    priv->hw->pcs != STMMAC_PCS_RTBI)
> +		stmmac_mdio_unregister(ndev);
>  error_mdio_register:
>  	netif_napi_del(&priv->napi);
>  error_hw_init:
> --
> 2.9.3

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

* Re: [PATCH net] net: stmmac: Fix error path after register_netdev move
  2016-12-28 23:44 [PATCH net] net: stmmac: Fix error path after register_netdev move Florian Fainelli
       [not found] ` <D6759987A7968C4889FDA6FA91D5CBC801CA3364@PGSMSX103.gar.corp.intel.com>
@ 2016-12-29 17:08 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-12-29 17:08 UTC (permalink / raw)
  To: f.fainelli
  Cc: netdev, pavel, Joao.Pinto, seraphin.bonnaffe, alexandre.torgue,
	manabian, niklas.cassel, johan, boon.leong.ong, weifeng.voon,
	lars.persson, linux-kernel, peppe.cavallaro, alexandre.torgue

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Wed, 28 Dec 2016 15:44:41 -0800

> Commit 5701659004d6 ("net: stmmac: Fix race between stmmac_drv_probe and
> stmmac_open") re-ordered how the MDIO bus registration and the network
> device are registered, but missed to unwind the MDIO bus registration in
> case we fail to register the network device.
> 
> Fixes: 5701659004d6 ("net: stmmac: Fix race between stmmac_drv_probe and stmmac_open")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied, thanks Florian.

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

end of thread, other threads:[~2016-12-29 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-28 23:44 [PATCH net] net: stmmac: Fix error path after register_netdev move Florian Fainelli
     [not found] ` <D6759987A7968C4889FDA6FA91D5CBC801CA3364@PGSMSX103.gar.corp.intel.com>
2016-12-29  9:36   ` Kweh, Hock Leong
2016-12-29 17:08 ` 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).