Skip to contentSkip to conversation

net: ethernet: broadcom: Fix uninitialized lockal variable

PATCH In review George Rurikov 2 participants 2 messages Oct 31, 2024

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

PATCH 1/1 net: ethernet: broadcom: Fix uninitialized lockal variable

I can't find any reason why it won't happen.
In SERDES_TG3_SGMII_MODE, when current_link_up == true and current_duplex == DUPLEX_FULL, program execution will be transferred using the goto fiber_setup_done, where the uninitialized remote_adv variable is passed as the second parameter to the tg3_setup_flow_control function.

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

Fixes 85730a631f0c ("tg3: Add SGMII phy support for 5719/5718 serdes")
---
 drivers/net/ethernet/broadcom/tg3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +2 -1
index 378815917741..b1c60851c841 100644
@@ -5802,7 +5802,8 @@ 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, sgsr;
+	u32 remote_adv = 0;
 
 	if ((tg3_asic_rev(tp) == ASIC_REV_5719 ||
 	     tg3_asic_rev(tp) == ASIC_REV_5720) &&
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 7 lines · George Rurikov

I can't find any reason why it won't happen.
In SERDES_TG3_SGMII_MODE, when current_link_up == true and current_duplex == DUPLEX_FULL, program execution will be transferred using the goto fiber_setup_done, where the uninitialized remote_adv variable is passed as the second parameter to the tg3_setup_flow_control function.

You mean the third parameter to the function. BTW, does this argument not hold good for local_adv also?

Quoted 27 lines

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

Fixes 85730a631f0c ("tg3: Add SGMII phy support for 5719/5718 serdes")
---
 drivers/net/ethernet/broadcom/tg3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +2 -2
index 378815917741..b1c60851c841 100644
@@ -5802,7 +5802,8 @@ 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, sgsr;
+       u32 remote_adv = 0;
 
        if ((tg3_asic_rev(tp) == ASIC_REV_5719 ||
             tg3_asic_rev(tp) == ASIC_REV_5720) &&
--

2.34.1