Skip to contentSkip to conversation

net: dsa: Add missing of_node_put() in dsa_port_parse_of

PATCH Applied Miaoqian Lin 3 participants 3 messages Mar 16, 2022 – Mar 17, 2022

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

PATCH 1/1 net: dsa: Add missing of_node_put() in dsa_port_parse_of

The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.

Fixes 6d4e5c570c2d ("net: dsa: get port type at parse time")
---
 net/dsa/dsa2.c | 1 +
 1 file changed, 1 insertion(+)
net/dsa/dsa2.c +1 -0
index b4e67758e104..1574f001725c 100644
@@ -1436,6 +1436,7 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)
 		const char *user_protocol;
 
 		master = of_find_net_device_by_node(ethernet);
+		of_node_put(ethernet);
 		if (!master)
 			return -EPROBE_DEFER;
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 5 lines · Miaoqian Lin

The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.

Fixes 6d4e5c570c2d ("net: dsa: get port type at parse time")

LGTM, thanks!

For the records, it looks like there is a similar issue in net/dsa/port.c: dsa_port_link_register_of().

Thanks!

Paolo

#2 lore raw
In reply to Miaoqian Lin
This patch was applied to netdev/net.git (master) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Wed, 16 Mar 2022 08:26:02 +0000 you wrote:

The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.

Fixes 6d4e5c570c2d ("net: dsa: get port type at parse time")
---
 net/dsa/dsa2.c | 1 +
 1 file changed, 1 insertion(+)

Here is the summary with links:
- net: dsa: Add missing of_node_put() in dsa_port_parse_of

    https://git.kernel.org/netdev/net/c/cb0b430b4e3a

You are awesome, thank you!

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