From 3e6f65ffcdde0fc50cdb49ffb78bfd1248fca906 Mon Sep 17 00:00:00 2001 From: Joachim Henze Date: Thu, 13 Jun 2024 21:24:23 +0200 Subject: [PATCH] [DC21X4] Fix uninitialized variable read (#6984) This is the network driver which is used for MSVPC 2007. I spotted it during a WIP-backport-experiment of the driver, when compiling with GCC4.7.2, which warned about it. GCC8.4.0 unfortunately is blind to that on master head, for unknown reasons. Not good. MSVC github buildbot is also blind to that on master head, for unknown reasons. Not good. We later found that at least Clang did also warn about it on master head. --- drivers/network/dd/dc21x4/media.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/network/dd/dc21x4/media.c b/drivers/network/dd/dc21x4/media.c index f5ae38661d6..ea35b20534b 100644 --- a/drivers/network/dd/dc21x4/media.c +++ b/drivers/network/dd/dc21x4/media.c @@ -326,7 +326,7 @@ MediaInitDefaultMedia( _In_ PDC21X4_ADAPTER Adapter, _In_ ULONG MediaNumber) { - ULONG Csr14, MiiAdvertising, MiiControl, i; + ULONG Csr14, i; BOOLEAN UseMii; PAGED_CODE(); @@ -471,12 +471,14 @@ MediaInitDefaultMedia( } else { + ULONG MiiAdvertising, MiiControl; Adapter->DefaultMedia = MEDIA_MII; switch (MediaNumber) { case MEDIA_10T: MiiAdvertising = MII_ADV_10T_HD; + MiiControl = 0; break; case MEDIA_10T_FD: MiiAdvertising = MII_ADV_10T_FD; @@ -491,9 +493,9 @@ MediaInitDefaultMedia( MiiControl = MII_CR_FULL_DUPLEX | MII_CR_SPEED_SELECTION; break; case MEDIA_100T4: - MiiAdvertising = MII_ADV_100T4 | MII_CR_SPEED_SELECTION; + MiiAdvertising = MII_ADV_100T4; + MiiControl = MII_CR_SPEED_SELECTION; break; - default: MiiAdvertising = 0; MiiControl = 0;