net: dsa: microchip: ksz_common: Fix refcount leak bug
PATCH v2 1/1 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.
---
changelog:
v2: use correct fix tag advised by Vladimir Oltean
v1: fix bug
v1 link: https://lore.kernel.org/all/[email protected]/
drivers/net/dsa/microchip/ksz_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz_common.c +4 -1
@@ -1038,18 +1038,21 @@ int ksz_switch_register(struct ksz_device *dev, ports =of_get_child_by_name (dev->dev->of_node,"ethernet-ports" );if (!ports) ports =of_get_child_by_name (dev->dev->of_node,"ports" ); -if (ports) +if (ports) {for_each_available_child_of_node (ports, port) {if (of_property_read_u32 (port,"reg" , &port_num))continue ;if (!(dev->port_mask &BIT (port_num))) {of_node_put (port); +of_node_put (ports);return -EINVAL ; }of_get_phy_mode (port, &dev->ports[port_num].interface); } +of_node_put (ports); + } dev->synclko_125 =of_property_read_bool (dev->dev->of_node,"microchip,synclko-125" ); dev->synclko_disable = of_property_read_bool(dev->dev->of_node,
Signature · 1 line
2.25.1
Quoted 7 lines · Liang He
In
ksz_switch_register(), we should callof_node_put()for the reference returned byof_get_child_by_name()which has increased the refcount.Fixes 912aae27c6af ("net: dsa: microchip: really look for phy-mode in port nodes")Signed-off-by Liang He <[email protected]>---
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 14 Jul 2022 23:31:38 +0800 you wrote:
In
ksz_switch_register(), we should callof_node_put()for the reference returned byof_get_child_by_name()which has increased the refcount.Fixes 912aae27c6af ("net: dsa: microchip: really look for phy-mode in port nodes")Signed-off-by Liang He <[email protected]>[...]
Here is the summary with links:
- [v2] net: dsa: microchip: ksz_common: Fix refcount leak bug
https://git.kernel.org/netdev/net/c/a14bd7475452
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html