Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ftgmac100: Hold reference returned by of_get_child_by_name()

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: 39bfab8844a0 ("net: ftgmac100: Add support for DT phy-handle property")
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Liang He and committed by
David S. Miller
49b9f431 7d5424b2

+14 -1
+14 -1
drivers/net/ethernet/faraday/ftgmac100.c
··· 1764 1764 return rc; 1765 1765 } 1766 1766 1767 + static bool ftgmac100_has_child_node(struct device_node *np, const char *name) 1768 + { 1769 + struct device_node *child_np = of_get_child_by_name(np, name); 1770 + bool ret = false; 1771 + 1772 + if (child_np) { 1773 + ret = true; 1774 + of_node_put(child_np); 1775 + } 1776 + 1777 + return ret; 1778 + } 1779 + 1767 1780 static int ftgmac100_probe(struct platform_device *pdev) 1768 1781 { 1769 1782 struct resource *res; ··· 1896 1883 1897 1884 /* Display what we found */ 1898 1885 phy_attached_info(phy); 1899 - } else if (np && !of_get_child_by_name(np, "mdio")) { 1886 + } else if (np && !ftgmac100_has_child_node(np, "mdio")) { 1900 1887 /* Support legacy ASPEED devicetree descriptions that decribe a 1901 1888 * MAC with an embedded MDIO controller but have no "mdio" 1902 1889 * child node. Automatically scan the MDIO bus for available