Commit cecd6e51 authored by Iyappan Subramanian's avatar Iyappan Subramanian Committed by David S. Miller

drivers: net: xgene: Fix error deconstruction path

Since register_netdev() call in xgene_enet_probe() was moved down to
the end, it doesn't properly handle errors that may occur, by
deconstructing everything that was setup before the error occurred.
Signed-off-by: default avatarIyappan Subramanian <isubramanian@apm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15e32296
...@@ -1641,8 +1641,8 @@ static int xgene_enet_probe(struct platform_device *pdev) ...@@ -1641,8 +1641,8 @@ static int xgene_enet_probe(struct platform_device *pdev)
} }
#endif #endif
if (!pdata->enet_id) { if (!pdata->enet_id) {
free_netdev(ndev); ret = -ENODEV;
return -ENODEV; goto err;
} }
ret = xgene_enet_get_resources(pdata); ret = xgene_enet_get_resources(pdata);
...@@ -1665,7 +1665,7 @@ static int xgene_enet_probe(struct platform_device *pdev) ...@@ -1665,7 +1665,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
ret = xgene_enet_init_hw(pdata); ret = xgene_enet_init_hw(pdata);
if (ret) if (ret)
goto err_netdev; goto err;
link_state = pdata->mac_ops->link_state; link_state = pdata->mac_ops->link_state;
if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) { if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) {
...@@ -1675,21 +1675,32 @@ static int xgene_enet_probe(struct platform_device *pdev) ...@@ -1675,21 +1675,32 @@ static int xgene_enet_probe(struct platform_device *pdev)
ret = xgene_enet_mdio_config(pdata); ret = xgene_enet_mdio_config(pdata);
else else
INIT_DELAYED_WORK(&pdata->link_work, link_state); INIT_DELAYED_WORK(&pdata->link_work, link_state);
}
if (ret) if (ret)
goto err; goto err1;
}
xgene_enet_napi_add(pdata); xgene_enet_napi_add(pdata);
ret = register_netdev(ndev); ret = register_netdev(ndev);
if (ret) { if (ret) {
netdev_err(ndev, "Failed to register netdev\n"); netdev_err(ndev, "Failed to register netdev\n");
goto err; goto err2;
} }
return 0; return 0;
err_netdev: err2:
unregister_netdev(ndev); /*
* If necessary, free_netdev() will call netif_napi_del() and undo
* the effects of xgene_enet_napi_add()'s calls to netif_napi_add().
*/
if (pdata->mdio_driver)
xgene_enet_phy_disconnect(pdata);
else if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII)
xgene_enet_mdio_remove(pdata);
err1:
xgene_enet_delete_desc_rings(pdata);
err: err:
free_netdev(ndev); free_netdev(ndev);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment