* [PATCH] net: stmmac: fix device node reference leaks in stmmac_mtl_setup()
@ 2026-08-21 5:57 Md Rabbani
2026-08-24 18:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Md Rabbani @ 2026-08-21 5:57 UTC (permalink / raw)
To: Maxime Chevallier, Alexandre Torgue, Maxime Coquelin,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-stm32, linux-arm-kernel, Md Rabbani
In stmmac_mtl_setup(), q_node is shared across the RX and TX queue
parsing loops. When the RX queue loop breaks early because the number
of parsed queues reaches plat->rx_queues_to_use, q_node retains an
acquired reference count. If the error check passes
(queue == plat->rx_queues_to_use), execution proceeds directly to the
TX queue loop, where of_get_next_child() immediately overwrites q_node
with the first TX child, permanently leaking the retained RX child
device node reference.
Switch both loops to for_each_child_of_node_scoped() so child node
references are automatically dropped upon loop exit or early break,
and remove the now-unnecessary function-scoped q_node variable and
its manual of_node_put() at the exit label.
Signed-off-by: Md Rabbani <rabbanyhmm@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index dc5f951a31..6128ed1bd5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -130,7 +130,6 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
static int stmmac_mtl_setup(struct platform_device *pdev,
struct plat_stmmacenet_data *plat)
{
- struct device_node *q_node;
struct device_node *rx_node;
struct device_node *tx_node;
u8 queue = 0;
@@ -169,7 +168,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
/* Processing individual RX queue config */
- for_each_child_of_node(rx_node, q_node) {
+ for_each_child_of_node_scoped(rx_node, q_node) {
if (queue >= plat->rx_queues_to_use)
break;
@@ -227,7 +226,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
queue = 0;
/* Processing individual TX queue config */
- for_each_child_of_node(tx_node, q_node) {
+ for_each_child_of_node_scoped(tx_node, q_node) {
if (queue >= plat->tx_queues_to_use)
break;
@@ -276,7 +275,6 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
out:
of_node_put(rx_node);
of_node_put(tx_node);
- of_node_put(q_node);
return ret;
}
--
2.55.0.windows.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] net: stmmac: fix device node reference leaks in stmmac_mtl_setup()
2026-08-21 5:57 [PATCH] net: stmmac: fix device node reference leaks in stmmac_mtl_setup() Md Rabbani
@ 2026-08-24 18:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-24 18:50 UTC (permalink / raw)
To: Md Rabbani
Cc: maxime.chevallier, alexandre.torgue, mcoquelin.stm32, davem,
edumazet, kuba, pabeni, netdev, linux-stm32, linux-arm-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 21 Aug 2026 11:57:18 +0600 you wrote:
> In stmmac_mtl_setup(), q_node is shared across the RX and TX queue
> parsing loops. When the RX queue loop breaks early because the number
> of parsed queues reaches plat->rx_queues_to_use, q_node retains an
> acquired reference count. If the error check passes
> (queue == plat->rx_queues_to_use), execution proceeds directly to the
> TX queue loop, where of_get_next_child() immediately overwrites q_node
> with the first TX child, permanently leaking the retained RX child
> device node reference.
>
> [...]
Here is the summary with links:
- net: stmmac: fix device node reference leaks in stmmac_mtl_setup()
https://git.kernel.org/netdev/net/c/317fe168f4c0
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] 2+ messages in thread
end of thread, other threads:[~2026-08-24 18:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21 5:57 [PATCH] net: stmmac: fix device node reference leaks in stmmac_mtl_setup() Md Rabbani
2026-08-24 18:50 ` 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