Skip to contentSkip to conversation

broadcom: b44: prevent uninitialized value usage

PATCH Applied Alexey Simakov 3 participants 3 messages Dec 5, 2025 – Dec 10, 2025

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

PATCH v3 1/1 broadcom: b44: prevent uninitialized value usage

On execution path with raised B44_FLAG_EXTERNAL_PHY, b44_readphy() leaves bmcr value uninitialized and it is used later in the code.

Add check of this flag at the beginning of the b44_nway_reset() and exit early of the function with restarting autonegotiation if an external PHY is used.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Fixes 753f492093da ("[B44]: port to native ssb support")

---

v2 - add restarting of autonegotiations by phy_ethtool_nway_reset(), instead of returning with 0 code (suggested by Jonas Gorski).

v3 - add needed mailing list into Cc.

link to v1: https://lore.kernel.org/all/[email protected]/
link to v2: https://lore.kernel.org/all/[email protected]/

 drivers/net/ethernet/broadcom/b44.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/b44.c +3 -0
index 0353359c3fe9..073d7d490d4b 100644
@@ -1789,6 +1789,9 @@ static int b44_nway_reset(struct net_device *dev)
 	u32 bmcr;
 	int r;
 
+	if (bp->flags & B44_FLAG_EXTERNAL_PHY)
+		return phy_ethtool_nway_reset(dev);
+
 	spin_lock_irq(&bp->lock);
 	b44_readphy(bp, MII_BMCR, &bmcr);
 	b44_readphy(bp, MII_BMCR, &bmcr);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v3 1/1
#1 lore raw
Quoted 8 lines · Alexey Simakov

On execution path with raised B44_FLAG_EXTERNAL_PHY, b44_readphy() leaves bmcr value uninitialized and it is used later in the code.

Add check of this flag at the beginning of the b44_nway_reset() and exit early of the function with restarting autonegotiation if an external PHY is used.

Quoted 6 lines

Found by Linux Verification Center (linuxtesting.org) with Svace.

Fixes 753f492093da ("[B44]: port to native ssb support")
#2 lore raw
In reply to Alexey Simakov
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 Fri, 5 Dec 2025 18:58:16 +0300 you wrote:

On execution path with raised B44_FLAG_EXTERNAL_PHY, b44_readphy() leaves bmcr value uninitialized and it is used later in the code.

Add check of this flag at the beginning of the b44_nway_reset() and exit early of the function with restarting autonegotiation if an external PHY is used.

[...]

Here is the summary with links:
- [net,v3] broadcom: b44: prevent uninitialized value usage

    https://git.kernel.org/netdev/net/c/50b3db3e1186

You are awesome, thank you!

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