]> www.infradead.org Git - users/hch/misc.git/commitdiff
tg3: prevent use of uninitialized remote_adv and local_adv variables
authorAlexey Simakov <bigalex934@gmail.com>
Tue, 14 Oct 2025 16:47:38 +0000 (19:47 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 16 Oct 2025 00:16:49 +0000 (17:16 -0700)
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.

Fixes: 85730a631f0c ("tg3: Add SGMII phy support for 5719/5718 serdes")
Co-developed-by: Alexandr Sapozhnikov <alsp705@gmail.com>
Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
Signed-off-by: Alexey Simakov <bigalex934@gmail.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://patch.msgid.link/20251014164736.5890-1-bigalex934@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/tg3.c

index 7f00ec7fd7b90dcd18fed75a90aa1aeaaf1b25a9..d78cafdb20949cd18c8070d72f6c4c8f2e827c20 100644 (file)
@@ -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;