Commit c41a4767 authored by Johan Hovold's avatar Johan Hovold Committed by David S. Miller

net: ethernet: dwc_eth_qos: fix fixed-link phydev leaks

Make sure to deregister and free any fixed-link PHY registered using
of_phy_register_fixed_link() on probe errors and on driver unbind.

Fixes: 077742da ("dwc_eth_qos: Add support for Synopsys DWC Ethernet
QoS")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9f70eb33
...@@ -2881,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev) ...@@ -2881,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev)
ret = of_get_phy_mode(lp->pdev->dev.of_node); ret = of_get_phy_mode(lp->pdev->dev.of_node);
if (ret < 0) { if (ret < 0) {
dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); dev_err(&lp->pdev->dev, "error in getting phy i/f\n");
goto err_out_clk_dis_phy; goto err_out_deregister_fixed_link;
} }
lp->phy_interface = ret; lp->phy_interface = ret;
...@@ -2889,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev) ...@@ -2889,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev)
ret = dwceqos_mii_init(lp); ret = dwceqos_mii_init(lp);
if (ret) { if (ret) {
dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n");
goto err_out_clk_dis_phy; goto err_out_deregister_fixed_link;
} }
ret = dwceqos_mii_probe(ndev); ret = dwceqos_mii_probe(ndev);
if (ret != 0) { if (ret != 0) {
netdev_err(ndev, "mii_probe fail.\n"); netdev_err(ndev, "mii_probe fail.\n");
ret = -ENXIO; ret = -ENXIO;
goto err_out_clk_dis_phy; goto err_out_deregister_fixed_link;
} }
dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0);
...@@ -2914,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev) ...@@ -2914,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n",
ret); ret);
goto err_out_clk_dis_phy; goto err_out_deregister_fixed_link;
} }
dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n",
pdev->id, ndev->base_addr, ndev->irq); pdev->id, ndev->base_addr, ndev->irq);
...@@ -2924,7 +2924,7 @@ static int dwceqos_probe(struct platform_device *pdev) ...@@ -2924,7 +2924,7 @@ static int dwceqos_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n",
ndev->irq, ret); ndev->irq, ret);
goto err_out_clk_dis_phy; goto err_out_deregister_fixed_link;
} }
if (netif_msg_probe(lp)) if (netif_msg_probe(lp))
...@@ -2935,11 +2935,14 @@ static int dwceqos_probe(struct platform_device *pdev) ...@@ -2935,11 +2935,14 @@ static int dwceqos_probe(struct platform_device *pdev)
ret = register_netdev(ndev); ret = register_netdev(ndev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
goto err_out_clk_dis_phy; goto err_out_deregister_fixed_link;
} }
return 0; return 0;
err_out_deregister_fixed_link:
if (of_phy_is_fixed_link(pdev->dev.of_node))
of_phy_deregister_fixed_link(pdev->dev.of_node);
err_out_clk_dis_phy: err_out_clk_dis_phy:
clk_disable_unprepare(lp->phy_ref_clk); clk_disable_unprepare(lp->phy_ref_clk);
err_out_clk_dis_aper: err_out_clk_dis_aper:
...@@ -2959,8 +2962,11 @@ static int dwceqos_remove(struct platform_device *pdev) ...@@ -2959,8 +2962,11 @@ static int dwceqos_remove(struct platform_device *pdev)
if (ndev) { if (ndev) {
lp = netdev_priv(ndev); lp = netdev_priv(ndev);
if (ndev->phydev) if (ndev->phydev) {
phy_disconnect(ndev->phydev); phy_disconnect(ndev->phydev);
if (of_phy_is_fixed_link(pdev->dev.of_node))
of_phy_deregister_fixed_link(pdev->dev.of_node);
}
mdiobus_unregister(lp->mii_bus); mdiobus_unregister(lp->mii_bus);
mdiobus_free(lp->mii_bus); mdiobus_free(lp->mii_bus);
......
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