Commit a14bd747 authored by Liang He's avatar Liang He Committed by Jakub Kicinski

net: dsa: microchip: ksz_common: Fix refcount leak bug

In ksz_switch_register(), we should call of_node_put() for the
reference returned by of_get_child_by_name() which has increased
the refcount.

Fixes: 912aae27 ("net: dsa: microchip: really look for phy-mode in port nodes")
Signed-off-by: default avatarLiang He <windhl@126.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/20220714153138.375919-1-windhl@126.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8f3184b9
...@@ -1038,18 +1038,21 @@ int ksz_switch_register(struct ksz_device *dev, ...@@ -1038,18 +1038,21 @@ int ksz_switch_register(struct ksz_device *dev,
ports = of_get_child_by_name(dev->dev->of_node, "ethernet-ports"); ports = of_get_child_by_name(dev->dev->of_node, "ethernet-ports");
if (!ports) if (!ports)
ports = of_get_child_by_name(dev->dev->of_node, "ports"); ports = of_get_child_by_name(dev->dev->of_node, "ports");
if (ports) if (ports) {
for_each_available_child_of_node(ports, port) { for_each_available_child_of_node(ports, port) {
if (of_property_read_u32(port, "reg", if (of_property_read_u32(port, "reg",
&port_num)) &port_num))
continue; continue;
if (!(dev->port_mask & BIT(port_num))) { if (!(dev->port_mask & BIT(port_num))) {
of_node_put(port); of_node_put(port);
of_node_put(ports);
return -EINVAL; return -EINVAL;
} }
of_get_phy_mode(port, of_get_phy_mode(port,
&dev->ports[port_num].interface); &dev->ports[port_num].interface);
} }
of_node_put(ports);
}
dev->synclko_125 = of_property_read_bool(dev->dev->of_node, dev->synclko_125 = of_property_read_bool(dev->dev->of_node,
"microchip,synclko-125"); "microchip,synclko-125");
dev->synclko_disable = of_property_read_bool(dev->dev->of_node, dev->synclko_disable = of_property_read_bool(dev->dev->of_node,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment