Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1cad5ee authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'more-phydev-leaks'



Johan Hovold says:

====================
net: fix phydev reference leaks

This series fixes a number of phydev reference leaks (and one of_node
leak) due to failure to put the reference taken by of_phy_find_device().

Note that I did not try to fix drivers/net/phy/xilinx_gmii2rgmii.c which
still leaks a reference.

Against net but should apply just as fine to net-next.

v2:
 - use put_device() instead of phy_dev_free() to put the references
   taken in net/dsa (patch 1/4).
 - add four new patches fixing similar leaks
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c9bd2823 6ffe1c4c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -542,8 +542,10 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
	/* Make sure we initialize MoCA PHYs with a link down */
	if (phy_mode == PHY_INTERFACE_MODE_MOCA) {
		phydev = of_phy_find_device(dn);
		if (phydev)
		if (phydev) {
			phydev->link = 0;
			put_device(&phydev->mdio.dev);
		}
	}

	return 0;
+3 −0
Original line number Diff line number Diff line
@@ -1107,6 +1107,9 @@ int memac_free(struct fman_mac *memac)
{
	free_init_resources(memac);

	if (memac->pcsphy)
		put_device(&memac->pcsphy->mdio.dev);

	kfree(memac->memac_drv_param);
	kfree(memac);

+2 −0
Original line number Diff line number Diff line
@@ -892,6 +892,8 @@ static int mac_probe(struct platform_device *_of_dev)
		priv->fixed_link->duplex = phy->duplex;
		priv->fixed_link->pause = phy->pause;
		priv->fixed_link->asym_pause = phy->asym_pause;

		put_device(&phy->mdio.dev);
	}

	err = mac_dev->init(mac_dev);
+1 −0
Original line number Diff line number Diff line
@@ -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);
		adpt->phydev = of_phy_find_device(phy_np);
		of_node_put(phy_np);
	}

	if (!adpt->phydev) {
+4 −0
Original line number Diff line number Diff line
@@ -711,6 +711,8 @@ static int emac_probe(struct platform_device *pdev)
err_undo_napi:
	netif_napi_del(&adpt->rx_q.napi);
err_undo_mdiobus:
	if (!has_acpi_companion(&pdev->dev))
		put_device(&adpt->phydev->mdio.dev);
	mdiobus_unregister(adpt->mii_bus);
err_undo_clocks:
	emac_clks_teardown(adpt);
@@ -730,6 +732,8 @@ static int emac_remove(struct platform_device *pdev)

	emac_clks_teardown(adpt);

	if (!has_acpi_companion(&pdev->dev))
		put_device(&adpt->phydev->mdio.dev);
	mdiobus_unregister(adpt->mii_bus);
	free_netdev(netdev);

Loading