* [PATCH v2] net: dsa: microchip: ksz_common: Fix refcount leak bug
@ 2022-07-14 15:31 Liang He
2022-07-14 15:35 ` Vladimir Oltean
2022-07-16 0:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Liang He @ 2022-07-14 15:31 UTC (permalink / raw)
To: woojung.huh, UNGLinuxDriver, andrew, vivien.didelot, f.fainelli,
olteanv, windhl, netdev
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: 912aae27c6af ("net: dsa: microchip: really look for phy-mode in port nodes")
Signed-off-by: Liang He <windhl@126.com>
---
changelog:
v2: use correct fix tag advised by Vladimir Oltean
v1: fix bug
v1 link: https://lore.kernel.org/all/20220713115428.367840-1-windhl@126.com/
drivers/net/dsa/microchip/ksz_common.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 9ca8c8d7740f..92a500e1ccd2 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -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,
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: dsa: microchip: ksz_common: Fix refcount leak bug
2022-07-14 15:31 [PATCH v2] net: dsa: microchip: ksz_common: Fix refcount leak bug Liang He
@ 2022-07-14 15:35 ` Vladimir Oltean
2022-07-16 0:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2022-07-14 15:35 UTC (permalink / raw)
To: Liang He
Cc: woojung.huh, UNGLinuxDriver, andrew, vivien.didelot, f.fainelli,
netdev
On Thu, Jul 14, 2022 at 11:31:38PM +0800, Liang He wrote:
> 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: 912aae27c6af ("net: dsa: microchip: really look for phy-mode in port nodes")
> Signed-off-by: Liang He <windhl@126.com>
> ---
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: dsa: microchip: ksz_common: Fix refcount leak bug
2022-07-14 15:31 [PATCH v2] net: dsa: microchip: ksz_common: Fix refcount leak bug Liang He
2022-07-14 15:35 ` Vladimir Oltean
@ 2022-07-16 0:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-16 0:20 UTC (permalink / raw)
To: Liang He
Cc: woojung.huh, UNGLinuxDriver, andrew, vivien.didelot, f.fainelli,
olteanv, netdev
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 14 Jul 2022 23:31:38 +0800 you wrote:
> 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: 912aae27c6af ("net: dsa: microchip: really look for phy-mode in port nodes")
> Signed-off-by: Liang He <windhl@126.com>
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-16 0:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-14 15:31 [PATCH v2] net: dsa: microchip: ksz_common: Fix refcount leak bug Liang He
2022-07-14 15:35 ` Vladimir Oltean
2022-07-16 0:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox