git: 36cd9f2ff331 - main - bnxt: avoid unintialized use of media_type in bnxt_add_media_types()

From: Andrew Gallatin <gallatin_at_FreeBSD.org>
Date: Wed, 04 Nov 2026 17:12:37 UTC
The branch main has been updated by gallatin:

URL: https://cgit.FreeBSD.org/src/commit/?id=36cd9f2ff3316e113eb2ed0c69b70695c0d9b9c8

commit 36cd9f2ff3316e113eb2ed0c69b70695c0d9b9c8
Author:     Andrew Gallatin <gallatin@FreeBSD.org>
AuthorDate: 2026-11-04 17:01:50 +0000
Commit:     Andrew Gallatin <gallatin@FreeBSD.org>
CommitDate: 2026-11-04 17:12:14 +0000

    bnxt: avoid unintialized use of media_type in bnxt_add_media_types()
    
    When 5e6e4f752833 landed, it inadvertently allowed unsupported / unknown
    phys with  a valid link_info->sig_mode to use  media_type uninitialized.
    Fix this by returning from those cases that do not assign a media_type
    so as to avoid using it uninitialized.
    
    Reported by: imp (forwarding an llm's post-commit review of previous
                      changes to this file)
    Fixes: 5e6e4f752833
    Reviewed by: imp, kbowling,  sumit.saxena_broadcom.com
    Sponsored by: Netflix
    Differential Revision: https://reviews.freebsd.org/D61164
---
 sys/dev/bnxt/bnxt_en/if_bnxt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/bnxt/bnxt_en/if_bnxt.c b/sys/dev/bnxt/bnxt_en/if_bnxt.c
index adbe36447683..c0d271a99924 100644
--- a/sys/dev/bnxt/bnxt_en/if_bnxt.c
+++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c
@@ -5526,12 +5526,12 @@ bnxt_add_media_types(struct bnxt_softc *softc)
 
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN:
 		/* Only Autoneg is supported for TYPE_UNKNOWN */
-		break;
+		return;
 
         default:
 		/* Only Autoneg is supported for new phy type values */
 		device_printf(softc->dev, "phy type %d not supported by driver\n", phy_type);
-		break;
+		return;
 	}
 
 	switch (link_info->sig_mode) {