Skip to contentSkip to conversation

fec: Fix fec_enet_alloc_buffers() error path

PATCH Applied Fabio Estevam 2 participants 2 messages Oct 4, 2014 – Oct 6, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fec: Fix fec_enet_alloc_buffers() error path

From: Fabio Estevam <[email protected]>

When fec_enet_alloc_buffers() fails we should better undo the previous actions, which consists of: disabling the FEC clocks and putting the FEC pins into inactive state.

The error path for fec_enet_mii_probe() is kept unchanged.

---
 drivers/net/ethernet/freescale/fec_main.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +10 -7
index 1f07db8..620feaf 100644
@@ -2746,16 +2746,12 @@ fec_enet_open(struct net_device *ndev)
 
 	ret = fec_enet_alloc_buffers(ndev);
 	if (ret)
-		return ret;
+		goto err_enet_alloc;
 
 	/* Probe and connect to PHY when open the interface */
 	ret = fec_enet_mii_probe(ndev);
-	if (ret) {
-		fec_enet_free_buffers(ndev);
-		fec_enet_clk_enable(ndev, false);
-		pinctrl_pm_select_sleep_state(&fep->pdev->dev);
-		return ret;
-	}
+	if (ret)
+		goto err_enet_mii_probe;
 
 	fec_restart(ndev);
 	napi_enable(&fep->napi);
@@ -2763,6 +2759,13 @@ fec_enet_open(struct net_device *ndev)
 	netif_tx_start_all_queues(ndev);
 
 	return 0;
+
+err_enet_mii_probe:
+	fec_enet_free_buffers(ndev);
+err_enet_alloc:
+	fec_enet_clk_enable(ndev, false);
+	pinctrl_pm_select_sleep_state(&fep->pdev->dev);
+	return ret;
 }
 
 static int
Signature · 1 line
1.9.1
maintainer Applied
#1 lore raw

From: Fabio Estevam <[email protected]>
Date: Sat, 4 Oct 2014 13:40:01 -0300

Quoted 9 lines

From: Fabio Estevam <[email protected]>

When fec_enet_alloc_buffers() fails we should better undo the previous actions, which consists of: disabling the FEC clocks and putting the FEC pins into inactive state.

The error path for fec_enet_mii_probe() is kept unchanged.

Applied, thanks Fabio.