Skip to content

Commit 994c548

Browse files
Timur Tabidavem330
authored andcommitted
net: qcom/emac: grab a reference to the phydev on ACPI systems
Commit 6ffe1c4 ("net: qcom/emac: fix of_node and phydev leaks") fixed the problem with reference leaks on phydev, but the fix is device-tree specific. When the driver unloads, the reference is dropped only on DT systems. Instead, it's cleaner if up grab an reference on ACPI systems. When the driver unloads, we can drop the reference without having to check whether we're on a DT system. Signed-off-by: Timur Tabi <[email protected]> Reviewed-by: Johan Hovold <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ea7a808 commit 994c548

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
201201
else
202202
adpt->phydev = mdiobus_get_phy(mii_bus, phy_addr);
203203

204+
/* of_phy_find_device() claims a reference to the phydev,
205+
* so we do that here manually as well. When the driver
206+
* later unloads, it can unilaterally drop the reference
207+
* without worrying about ACPI vs DT.
208+
*/
209+
if (adpt->phydev)
210+
get_device(&adpt->phydev->mdio.dev);
204211
} else {
205212
struct device_node *phy_np;
206213

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,7 @@ static int emac_probe(struct platform_device *pdev)
719719
err_undo_napi:
720720
netif_napi_del(&adpt->rx_q.napi);
721721
err_undo_mdiobus:
722-
if (!has_acpi_companion(&pdev->dev))
723-
put_device(&adpt->phydev->mdio.dev);
722+
put_device(&adpt->phydev->mdio.dev);
724723
mdiobus_unregister(adpt->mii_bus);
725724
err_undo_clocks:
726725
emac_clks_teardown(adpt);
@@ -740,8 +739,7 @@ static int emac_remove(struct platform_device *pdev)
740739

741740
emac_clks_teardown(adpt);
742741

743-
if (!has_acpi_companion(&pdev->dev))
744-
put_device(&adpt->phydev->mdio.dev);
742+
put_device(&adpt->phydev->mdio.dev);
745743
mdiobus_unregister(adpt->mii_bus);
746744
free_netdev(netdev);
747745

0 commit comments

Comments
 (0)