mirror of
https://github.com/torvalds/linux.git
synced 2024-12-01 00:21:32 +00:00
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: 077742dac2
("dwc_eth_qos: Add support for Synopsys DWC Ethernet
QoS")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
9f70eb339f
commit
c41a47678d
@ -2881,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev)
|
||||
ret = of_get_phy_mode(lp->pdev->dev.of_node);
|
||||
if (ret < 0) {
|
||||
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;
|
||||
@ -2889,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev)
|
||||
ret = dwceqos_mii_init(lp);
|
||||
if (ret) {
|
||||
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);
|
||||
if (ret != 0) {
|
||||
netdev_err(ndev, "mii_probe fail.\n");
|
||||
ret = -ENXIO;
|
||||
goto err_out_clk_dis_phy;
|
||||
goto err_out_deregister_fixed_link;
|
||||
}
|
||||
|
||||
dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0);
|
||||
@ -2914,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev)
|
||||
if (ret) {
|
||||
dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n",
|
||||
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",
|
||||
pdev->id, ndev->base_addr, ndev->irq);
|
||||
@ -2924,7 +2924,7 @@ static int dwceqos_probe(struct platform_device *pdev)
|
||||
if (ret) {
|
||||
dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n",
|
||||
ndev->irq, ret);
|
||||
goto err_out_clk_dis_phy;
|
||||
goto err_out_deregister_fixed_link;
|
||||
}
|
||||
|
||||
if (netif_msg_probe(lp))
|
||||
@ -2935,11 +2935,14 @@ static int dwceqos_probe(struct platform_device *pdev)
|
||||
ret = register_netdev(ndev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
|
||||
goto err_out_clk_dis_phy;
|
||||
goto err_out_deregister_fixed_link;
|
||||
}
|
||||
|
||||
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:
|
||||
clk_disable_unprepare(lp->phy_ref_clk);
|
||||
err_out_clk_dis_aper:
|
||||
@ -2959,8 +2962,11 @@ static int dwceqos_remove(struct platform_device *pdev)
|
||||
if (ndev) {
|
||||
lp = netdev_priv(ndev);
|
||||
|
||||
if (ndev->phydev)
|
||||
if (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_free(lp->mii_bus);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user