diff options
author | Johan Hovold <johan@kernel.org> | 2016-11-24 13:21:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-27 20:01:15 -0500 |
commit | 6ffe1c4cd0a77f51d8d2985aa721d636b03ddf58 (patch) | |
tree | 0c8c0a6f7970c96c4827a06f9c0d0e19b9e62e48 /drivers/net/ethernet/qualcomm | |
parent | cb1f3410ff12520b22fa03ccd23892c360de0c26 (diff) |
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: b9b17debc69d ("net: emac: emac gigabit ethernet controller driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/qualcomm')
-rw-r--r-- | drivers/net/ethernet/qualcomm/emac/emac-phy.c | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/qualcomm/emac/emac.c | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-phy.c b/drivers/net/ethernet/qualcomm/emac/emac-phy.c index da4e90db4d98..99a14df28b96 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac-phy.c +++ b/drivers/net/ethernet/qualcomm/emac/emac-phy.c | |||
@@ -212,6 +212,7 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt) | |||
212 | 212 | ||
213 | phy_np = of_parse_phandle(np, "phy-handle", 0); | 213 | phy_np = of_parse_phandle(np, "phy-handle", 0); |
214 | adpt->phydev = of_phy_find_device(phy_np); | 214 | adpt->phydev = of_phy_find_device(phy_np); |
215 | of_node_put(phy_np); | ||
215 | } | 216 | } |
216 | 217 | ||
217 | if (!adpt->phydev) { | 218 | if (!adpt->phydev) { |
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c index 4fede4b86538..57b35aeac51a 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac.c +++ b/drivers/net/ethernet/qualcomm/emac/emac.c | |||
@@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev) | |||
711 | err_undo_napi: | 711 | err_undo_napi: |
712 | netif_napi_del(&adpt->rx_q.napi); | 712 | netif_napi_del(&adpt->rx_q.napi); |
713 | err_undo_mdiobus: | 713 | err_undo_mdiobus: |
714 | if (!has_acpi_companion(&pdev->dev)) | ||
715 | put_device(&adpt->phydev->mdio.dev); | ||
714 | mdiobus_unregister(adpt->mii_bus); | 716 | mdiobus_unregister(adpt->mii_bus); |
715 | err_undo_clocks: | 717 | err_undo_clocks: |
716 | emac_clks_teardown(adpt); | 718 | emac_clks_teardown(adpt); |
@@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev) | |||
730 | 732 | ||
731 | emac_clks_teardown(adpt); | 733 | emac_clks_teardown(adpt); |
732 | 734 | ||
735 | if (!has_acpi_companion(&pdev->dev)) | ||
736 | put_device(&adpt->phydev->mdio.dev); | ||
733 | mdiobus_unregister(adpt->mii_bus); | 737 | mdiobus_unregister(adpt->mii_bus); |
734 | free_netdev(netdev); | 738 | free_netdev(netdev); |
735 | 739 | ||