提交 6ffe1c4c 编写于 作者: J Johan Hovold 提交者: David S. Miller

net: qcom/emac: fix of_node and phydev leaks

Make sure to drop the reference taken by of_phy_find_device() during
probe on probe errors and on driver unbind.

Also drop the of_node reference taken by of_parse_phandle() in the same
path.

Fixes: b9b17deb ("net: emac: emac gigabit ethernet controller driver")
Signed-off-by: NJohan Hovold <johan@kernel.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 cb1f3410
...@@ -212,6 +212,7 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt) ...@@ -212,6 +212,7 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
phy_np = of_parse_phandle(np, "phy-handle", 0); phy_np = of_parse_phandle(np, "phy-handle", 0);
adpt->phydev = of_phy_find_device(phy_np); adpt->phydev = of_phy_find_device(phy_np);
of_node_put(phy_np);
} }
if (!adpt->phydev) { if (!adpt->phydev) {
......
...@@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev) ...@@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev)
err_undo_napi: err_undo_napi:
netif_napi_del(&adpt->rx_q.napi); netif_napi_del(&adpt->rx_q.napi);
err_undo_mdiobus: err_undo_mdiobus:
if (!has_acpi_companion(&pdev->dev))
put_device(&adpt->phydev->mdio.dev);
mdiobus_unregister(adpt->mii_bus); mdiobus_unregister(adpt->mii_bus);
err_undo_clocks: err_undo_clocks:
emac_clks_teardown(adpt); emac_clks_teardown(adpt);
...@@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev) ...@@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev)
emac_clks_teardown(adpt); emac_clks_teardown(adpt);
if (!has_acpi_companion(&pdev->dev))
put_device(&adpt->phydev->mdio.dev);
mdiobus_unregister(adpt->mii_bus); mdiobus_unregister(adpt->mii_bus);
free_netdev(netdev); free_netdev(netdev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册