diff mbox series

net: ethernet: broadcom: Fix uninitialized lockal variable

Message ID 20241031173232.1776-1-grurikov@gmail.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet: broadcom: Fix uninitialized lockal variable | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-11-01--00-00 (tests: 110)

Commit Message

George Rurikov Oct. 31, 2024, 5:32 p.m. UTC
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")
Cc: stable@vger.kernel.org
Signed-off-by: George Rurikov <grurikov@gmail.com>
---
 drivers/net/ethernet/broadcom/tg3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Pavan Chebbi Oct. 31, 2024, 5:54 p.m. UTC | #1
On Thu, Oct 31, 2024 at 11:02 PM George Rurikov <grurikov@gmail.com> wrote:
>
> 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?

>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 85730a631f0c ("tg3: Add SGMII phy support for 5719/5718 serdes")
> Cc: stable@vger.kernel.org
> Signed-off-by: George Rurikov <grurikov@gmail.com>
> ---
>  drivers/net/ethernet/broadcom/tg3.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 378815917741..b1c60851c841 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -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
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 378815917741..b1c60851c841 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -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) &&