Skip to contentSkip to conversation

net: dsa: lantiq_gswip: Fix refcount leak in gswip_gphy_fw_list

PATCH Applied Miaoqian Lin 2 participants 2 messages Jun 5, 2022 – Jun 8, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dsa: lantiq_gswip: Fix refcount leak in gswip_gphy_fw_list

Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node.
when breaking early from a for_each_available_child_of_node() loop, we need to explicitly call of_node_put() on the gphy_fw_np. Add missing of_node_put() to avoid refcount leak.

Fixes 14fceff4771e ("net: dsa: Add Lantiq / Intel DSA driver for vrx200")
---
 drivers/net/dsa/lantiq_gswip.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/lantiq_gswip.c +3 -1
index 8af4def38a98..e531b93f3cb2 100644
@@ -2070,8 +2070,10 @@ static int gswip_gphy_fw_list(struct gswip_priv *priv,
 	for_each_available_child_of_node(gphy_fw_list_np, gphy_fw_np) {
 		err = gswip_gphy_fw_probe(priv, &priv->gphy_fw[i],
 					  gphy_fw_np, i);
-		if (err)
+		if (err) {
+			of_node_put(gphy_fw_np);
 			goto remove_gphy;
+		}
 		i++;
 	}
 
Signature · 1 line
2.25.1
#1 lore raw
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 10 lines · On Sun, 5 Jun 2022 11:23:34 +0400 you wrote:

Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node.
when breaking early from a for_each_available_child_of_node() loop, we need to explicitly call of_node_put() on the gphy_fw_np. Add missing of_node_put() to avoid refcount leak.

Fixes 14fceff4771e ("net: dsa: Add Lantiq / Intel DSA driver for vrx200")

[...]

Here is the summary with links:
- net: dsa: lantiq_gswip: Fix refcount leak in gswip_gphy_fw_list

    https://git.kernel.org/netdev/net/c/0737e018a05e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html