提交 95497337 编写于 作者: L Liang He 提交者: Zheng Zengkai

net: ftgmac100: Hold reference returned by of_get_child_by_name()

stable inclusion
from stable-v5.10.132
commit 29c6a632f8193b0a4b40156afb823371d1d4c05a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5YS3T

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=29c6a632f8193b0a4b40156afb823371d1d4c05a

--------------------------------

[ Upstream commit 49b9f431 ]

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: NLiang He <windhl@126.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 1fe157dd
......@@ -1753,6 +1753,19 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv)
return rc;
}
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;
......@@ -1866,7 +1879,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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册