broadcom: b44: prevent uninitialized value usage
Subsystems (2)
PATCH v2 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.
---
v2 - add restarting of autonegotiations by phy_ethtool_nway_reset(), instead of returning with 0 code (suggested by Jonas Gorski).
link to v1: 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
@@ -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
Quoted 27 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.Found by Linux Verification Center (linuxtesting.org) with Svace.
Fixes 753f492093da ("[B44]: port to native ssb support")Signed-off-by Alexey Simakov <[email protected]>---
v2 - add restarting of autonegotiations by
phy_ethtool_nway_reset(), instead of returning with 0 code (suggested by Jonas Gorski).link to v1: 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 +0
-0
drivers/net/ethernet/broadcom/b44.c static int b44_nway_reset(struct net_device *dev) · line 1793
Quoted 5 lines
drivers/net/ethernet/broadcom/b44.c +2
-0@@ -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);
Thanks for double checking and not blindly copying my suggestion lol. (phy_ethtool_nway_reset() takes a net_device *, not a phy_device * ...).
In that sense,
Best regards,
Jonas
Paolo Abeni
maintainerQuoted 11 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.Found by Linux Verification Center (linuxtesting.org) with Svace.
Fixes 753f492093da ("[B44]: port to native ssb support")Signed-off-by Alexey Simakov <[email protected]>
You need to include the netdev ML in the recipients list to get this patch processed.
Thanks,
Paolo
Quoted 11 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.Found by Linux Verification Center (linuxtesting.org) with Svace.
Fixes 753f492093da ("[B44]: port to native ssb support")Signed-off-by Alexey Simakov <[email protected]>
Andrew