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

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

Merge branch 'net-of_node_put'



Peter Chen says:

====================
add missing of_node_put after calling of_parse_phandle

This patch set fixes missing of_node_put issue at ethernet driver.
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

The compilation test has passed by using allmodconfig for drivers/net/ethernet.

Changes for v2:
- If the device node is local variable, it can be put in the same function.
- If the device node will be used the whole driver life cycle,
  it should be put (call of_node_put) at driver's remove.
  Patch [4, 5, 9, 14, 15/15]
- Fix the issue that the node still be used at error patch [6/15]
- Add acked for patch [11,12/15]
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0a2f0d2d 5817f977
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -815,6 +815,7 @@ static int init_phy(struct net_device *dev)
		phydev = of_phy_connect(dev, phynode,
			&altera_tse_adjust_link, 0, priv->phy_iface);
	}
	of_node_put(phynode);

	if (!phydev) {
		netdev_err(dev, "Could not find the PHY\n");
+1 −0
Original line number Diff line number Diff line
@@ -772,6 +772,7 @@ int xgene_enet_phy_connect(struct net_device *ndev)

		phy_dev = of_phy_connect(ndev, np, &xgene_enet_adjust_link,
					 0, pdata->phy_mode);
		of_node_put(np);
		if (!phy_dev) {
			netdev_err(ndev, "Could not connect to PHY\n");
			return -ENODEV;
+11 −4
Original line number Diff line number Diff line
@@ -749,14 +749,16 @@ int arc_emac_probe(struct net_device *ndev, int interface)
	err = of_address_to_resource(dev->of_node, 0, &res_regs);
	if (err) {
		dev_err(dev, "failed to retrieve registers base from device tree\n");
		return -ENODEV;
		err = -ENODEV;
		goto out_put_node;
	}

	/* Get IRQ from device tree */
	irq = irq_of_parse_and_map(dev->of_node, 0);
	if (!irq) {
		dev_err(dev, "failed to retrieve <irq> value from device tree\n");
		return -ENODEV;
		err = -ENODEV;
		goto out_put_node;
	}

	ndev->netdev_ops = &arc_emac_netdev_ops;
@@ -778,7 +780,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
		err = clk_prepare_enable(priv->clk);
		if (err) {
			dev_err(dev, "failed to enable clock\n");
			return err;
			goto out_put_node;
		}

		clock_frequency = clk_get_rate(priv->clk);
@@ -787,7 +789,8 @@ int arc_emac_probe(struct net_device *ndev, int interface)
		if (of_property_read_u32(dev->of_node, "clock-frequency",
					 &clock_frequency)) {
			dev_err(dev, "failed to retrieve <clock-frequency> from device tree\n");
			return -EINVAL;
			err = -EINVAL;
			goto out_put_node;
		}
	}

@@ -867,6 +870,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
		goto out_netif_api;
	}

	of_node_put(phy_node);
	return 0;

out_netif_api:
@@ -877,6 +881,9 @@ int arc_emac_probe(struct net_device *ndev, int interface)
out_clken:
	if (priv->clk)
		clk_disable_unprepare(priv->clk);
out_put_node:
	of_node_put(phy_node);

	return err;
}
EXPORT_SYMBOL_GPL(arc_emac_probe);
+2 −0
Original line number Diff line number Diff line
@@ -1504,6 +1504,7 @@ static int nb8800_probe(struct platform_device *pdev)
err_free_dma:
	nb8800_dma_free(dev);
err_free_bus:
	of_node_put(priv->phy_node);
	mdiobus_unregister(bus);
err_disable_clk:
	clk_disable_unprepare(priv->clk);
@@ -1519,6 +1520,7 @@ static int nb8800_remove(struct platform_device *pdev)
	struct nb8800_priv *priv = netdev_priv(ndev);

	unregister_netdev(ndev);
	of_node_put(priv->phy_node);

	mdiobus_unregister(priv->mii_bus);

+3 −0
Original line number Diff line number Diff line
@@ -1513,6 +1513,7 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
	return 0;

err:
	of_node_put(p->phy_np);
	free_netdev(netdev);
	return result;
}
@@ -1520,8 +1521,10 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
static int octeon_mgmt_remove(struct platform_device *pdev)
{
	struct net_device *netdev = platform_get_drvdata(pdev);
	struct octeon_mgmt *p = netdev_priv(netdev);

	unregister_netdev(netdev);
	of_node_put(p->phy_np);
	free_netdev(netdev);
	return 0;
}
Loading