Skip to contentSkip to conversation

stmmac: intel: Fix kernel crash due to wrong error path

PATCH Applied Andy Shevchenko 2 participants 2 messages Apr 29, 2020 – May 1, 2020

Subsystems (4)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stmmac: intel: Fix kernel crash due to wrong error path

Unfortunately sometimes ->probe() may fail. The commit b9663b7ca6ff ("net: stmmac: Enable SERDES power up/down sequence") messed up with error handling and thus:

[   12.811311] ------------[ cut here ]------------
[   12.811993] kernel BUG at net/core/dev.c:9937!

Fix this by properly crafted error path.

Fixes b9663b7ca6ff ("net: stmmac: Enable SERDES power up/down sequence")
Cc Voon Weifeng <[email protected]>
Cc Ong Boon Leong <[email protected]>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -1
index 565da6498c846e..ff22f274aa43d6 100644
@@ -4991,7 +4991,7 @@ int stmmac_dvr_probe(struct device *device,
 						 priv->plat->bsp_priv);
 
 		if (ret < 0)
-			return ret;
+			goto error_serdes_powerup;
 	}
 
 #ifdef CONFIG_DEBUG_FS
@@ -5000,6 +5000,8 @@ int stmmac_dvr_probe(struct device *device,
 
 	return ret;
 
+error_serdes_powerup:
+	unregister_netdev(ndev);
 error_netdev_register:
 	phylink_destroy(priv->phylink);
 error_phy_setup:
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw

From: Andy Shevchenko <[email protected]>
Date: Wed, 29 Apr 2020 18:09:32 +0300

Quoted 7 lines

Unfortunately sometimes ->probe() may fail. The commit b9663b7ca6ff ("net: stmmac: Enable SERDES power up/down sequence") messed up with error handling and thus:

[   12.811311] ------------[ cut here ]------------
[   12.811993] kernel BUG at net/core/dev.c:9937!
Quoted 6 lines

Fix this by properly crafted error path.

Fixes b9663b7ca6ff ("net: stmmac: Enable SERDES power up/down sequence")
Cc Voon Weifeng <[email protected]>
Cc Ong Boon Leong <[email protected]>

Applied.