[net,stable,1/1] net: fec: free/restore resource in related probe error pathes

Message ID 1515034040-12482-1-git-send-email-fugang.duan@nxp.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net,stable,1/1] net: fec: free/restore resource in related probe error pathes
Related show

Commit Message

Andy Duan Jan. 4, 2018, 2:47 a.m.
Fixes in probe error path:
- Restore dev_id before failed_ioremap path.
  Fixes: ("net: fec: restore dev_id in the cases of probe error")
- Call of_node_put(phy_node) before failed_phy path.
  Fixes: ("net: fec: Support phys probed from devicetree and fixed-link")

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller Jan. 5, 2018, 4:20 p.m. | #1
From: Fugang Duan <fugang.duan@nxp.com>
Date: Thu, 4 Jan 2018 10:47:20 +0800

> Fixes in probe error path:
> - Restore dev_id before failed_ioremap path.
>   Fixes: ("net: fec: restore dev_id in the cases of probe error")
> - Call of_node_put(phy_node) before failed_phy path.
>   Fixes: ("net: fec: Support phys probed from devicetree and fixed-link")
> 
> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>

Applied.

Patch

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index feed383..90aa69a 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3576,11 +3576,11 @@  static int fec_enet_get_irq_cnt(struct platform_device *pdev)
 failed_clk:
 	if (of_phy_is_fixed_link(np))
 		of_phy_deregister_fixed_link(np);
-failed_phy:
 	of_node_put(phy_node);
+failed_phy:
+	dev_id--;
 failed_ioremap:
 	free_netdev(ndev);
-	dev_id--;
 
 	return ret;
 }