Skip to content

Commit 6ffe1c4

Browse files
jhovolddavem330
authored andcommitted
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: b9b17de ("net: emac: emac gigabit ethernet controller driver") Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cb1f341 commit 6ffe1c4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

drivers/net/ethernet/qualcomm/emac/emac-phy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
212212

213213
phy_np = of_parse_phandle(np, "phy-handle", 0);
214214
adpt->phydev = of_phy_find_device(phy_np);
215+
of_node_put(phy_np);
215216
}
216217

217218
if (!adpt->phydev) {

drivers/net/ethernet/qualcomm/emac/emac.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev)
711711
err_undo_napi:
712712
netif_napi_del(&adpt->rx_q.napi);
713713
err_undo_mdiobus:
714+
if (!has_acpi_companion(&pdev->dev))
715+
put_device(&adpt->phydev->mdio.dev);
714716
mdiobus_unregister(adpt->mii_bus);
715717
err_undo_clocks:
716718
emac_clks_teardown(adpt);
@@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev)
730732

731733
emac_clks_teardown(adpt);
732734

735+
if (!has_acpi_companion(&pdev->dev))
736+
put_device(&adpt->phydev->mdio.dev);
733737
mdiobus_unregister(adpt->mii_bus);
734738
free_netdev(netdev);
735739

0 commit comments

Comments
 (0)