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

Commit b8d77f23 authored by Liang He's avatar Liang He Committed by Greg Kroah-Hartman
Browse files

net: ftgmac100: Hold reference returned by of_get_child_by_name()



[ Upstream commit 49b9f431ff0d845a36be0b3ede35ec324f2e5fee ]

In ftgmac100_probe(), we should hold the refernece returned by
of_get_child_by_name() and use it to call of_node_put() for
reference balance.

Fixes: 39bfab88 ("net: ftgmac100: Add support for DT phy-handle property")
Signed-off-by: default avatarLiang He <windhl@126.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9b61d3f6
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -1734,6 +1734,19 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
			FTGMAC_100MHZ);
}

static bool ftgmac100_has_child_node(struct device_node *np, const char *name)
{
	struct device_node *child_np = of_get_child_by_name(np, name);
	bool ret = false;

	if (child_np) {
		ret = true;
		of_node_put(child_np);
	}

	return ret;
}

static int ftgmac100_probe(struct platform_device *pdev)
{
	struct resource *res;
@@ -1850,7 +1863,7 @@ static int ftgmac100_probe(struct platform_device *pdev)

		/* Display what we found */
		phy_attached_info(phy);
	} else if (np && !of_get_child_by_name(np, "mdio")) {
	} else if (np && !ftgmac100_has_child_node(np, "mdio")) {
		/* Support legacy ASPEED devicetree descriptions that decribe a
		 * MAC with an embedded MDIO controller but have no "mdio"
		 * child node. Automatically scan the MDIO bus for available