tg3: prevent use of uninitialized remote_adv and local_adv variables
Subsystems (3)
PATCH v2 1/1 tg3: prevent use of uninitialized remote_adv and local_adv variables
Some execution paths that jump to the fiber_setup_done label could leave the remote_adv and local_adv variables uninitialized and then use it.
Initialize this variables at the point of definition to avoid this.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
---
v2 - remove bogus lines with initialization of variables in function, since its initialized at definition point now.
link to v1: https://lore.kernel.org/netdev/[email protected]/
drivers/net/ethernet/broadcom/tg3.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +1 -4
@@ -5803,7 +5803,7 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)u32 current_speed =SPEED_UNKNOWN ;u8 current_duplex =DUPLEX_UNKNOWN ;bool current_link_up = false; -u32 local_adv, remote_adv, sgsr; +u32 local_adv =0 , remote_adv =0 , sgsr; if ((tg3_asic_rev(tp) == ASIC_REV_5719 || tg3_asic_rev(tp) == ASIC_REV_5720) &&
@@ -5944,9 +5944,6 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)else current_duplex =DUPLEX_HALF ; - local_adv =0 ; - remote_adv =0 ; -if (bmcr &BMCR_ANENABLE ) {u32 common;
Signature · 1 line
2.34.1
Quoted 5 lines · Alexey Simakov
Some execution paths that jump to the
fiber_setup_donelabel could leave theremote_advandlocal_advvariables uninitialized and then use it.
Quoted 8 lines
Initialize this variables at the point of definition to avoid this.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 85730a631f0c ("tg3: Add SGMII phy support for 5719/5718 serdes")Co-developed-by Alexandr Sapozhnikov <[email protected]>Signed-off-by Alexandr Sapozhnikov <[email protected]>Signed-off-by Alexey Simakov <[email protected]>
LGTM.
Quoted 35 lines
---
v2 - remove bogus lines with initialization of variables in function, since its initialized at definition point now.
link to v1: https://lore.kernel.org/netdev/[email protected]/
drivers/net/ethernet/broadcom/tg3.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/net/ethernet/broadcom/tg3.c +1
-5@@ -5803,7 +5803,7 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)u32 current_speed =SPEED_UNKNOWN ;u8 current_duplex =DUPLEX_UNKNOWN ;bool current_link_up = false; -u32 local_adv, remote_adv, sgsr; +u32 local_adv =0 , remote_adv =0 , sgsr; if ((tg3_asic_rev(tp) == ASIC_REV_5719 || tg3_asic_rev(tp) == ASIC_REV_5720) &&@@ -5944,9 +5944,6 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)else current_duplex =DUPLEX_HALF ; - local_adv =0 ; - remote_adv =0 ; -if (bmcr &BMCR_ANENABLE ) {u32 common; --2.34.1
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 9 lines · On Tue, 14 Oct 2025 19:47:38 +0300 you wrote:
Some execution paths that jump to the
fiber_setup_donelabel could leave theremote_advandlocal_advvariables uninitialized and then use it.Initialize this variables at the point of definition to avoid this.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
[...]
Here is the summary with links:
- [net,v2] tg3: prevent use of uninitialized remote_adv and local_adv variables
https://git.kernel.org/netdev/net/c/0c3f2e62815a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html