Skip to contentSkip to conversation

net: thunder_bgx: decrement cleanup index before use

PATCH Applied Rosen Penev 4 participants 4 messages Sep 1, 2025 – Sep 4, 2025

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

PATCH 1/1 net: thunder_bgx: decrement cleanup index before use

All paths in probe that call goto defer do so before assigning phydev and thus it makes sense to cleanup the prior index. It also fixes a bug where index 0 does not get cleaned up.

Fixes b7d3e3d3d21a ("net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition.")
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +1 -1
index 21495b5dce25..90c718af06c1 100644
@@ -1515,11 +1515,11 @@ static int bgx_init_of_phy(struct bgx *bgx)
 	 * for phy devices we may have already found.
 	 */
 	while (lmac) {
+		lmac--;
 		if (bgx->lmac[lmac].phydev) {
 			put_device(&bgx->lmac[lmac].phydev->mdio.dev);
 			bgx->lmac[lmac].phydev = NULL;
 		}
-		lmac--;
 	}
 	of_node_put(node);
 	return -EPROBE_DEFER;
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Rosen Penev

All paths in probe that call goto defer do so before assigning phydev and thus it makes sense to cleanup the prior index. It also fixes a bug where index 0 does not get cleaned up.

Fixes b7d3e3d3d21a ("net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition.")
---
  drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +0 -0
index 21495b5dce25..90c718af06c1 100644
@@ -1515,11 +1515,11 @@ static int bgx_init_of_phy(struct bgx *bgx)
  	 * for phy devices we may have already found.
  	 */

drivers/net/ethernet/cavium/thunder/thunder_bgx.c static int bgx_init_of_phy(struct bgx *bgx) · line 1525

Quoted 10 lines
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +1 -1
  	while (lmac) {
+		lmac--;
  		if (bgx->lmac[lmac].phydev) {
  			put_device(&bgx->lmac[lmac].phydev->mdio.dev);
  			bgx->lmac[lmac].phydev = NULL;
  		}
-		lmac--;
  	}
  	of_node_put(node);
  	return -EPROBE_DEFER;
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Rosen Penev
Quoted 6 lines · Rosen Penev

All paths in probe that call goto defer do so before assigning phydev and thus it makes sense to cleanup the prior index. It also fixes a bug where index 0 does not get cleaned up.

Fixes b7d3e3d3d21a ("net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition.")

As I reviewed an earlier revision (yesterday)
where this was part of another patch:

#3 lore raw
In reply to Rosen Penev
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 1 Sep 2025 14:33:14 -0700 you wrote:

All paths in probe that call goto defer do so before assigning phydev and thus it makes sense to cleanup the prior index. It also fixes a bug where index 0 does not get cleaned up.

Fixes b7d3e3d3d21a ("net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition.")

[...]

Here is the summary with links:
- [net] net: thunder_bgx: decrement cleanup index before use

    https://git.kernel.org/netdev/net/c/9e3d71a92e56

You are awesome, thank you!

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