From: Ruoyu Wang <ruoyuw560@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Ruoyu Wang <ruoyuw560@gmail.com>
Subject: [PATCH net] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error
Date: Fri, 14 Aug 2026 21:40:06 +0800 [thread overview]
Message-ID: <20260814134006.1386372-1-ruoyuw560@gmail.com> (raw)
An SMI timeout or PPU access failure can make a Clause 22 PHY read
return without initializing its output value. When reading MII_PHYSID2,
mv88e6xxx_mdio_read() still passes that value through the internal PHY
model-number workaround before returning the error, causing an
uninitialized stack read.
Run the workaround only after a successful PHY read. This preserves the
original error and leaves successful PHY ID reads unchanged.
This issue was found by a static analysis checker and confirmed by
manual source review.
Fixes: da9f33018e2c ("net: dsa: mv88e6xxx: Workaround missing PHY ID on mv88e6390")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 80b877c74513d..e71707ce71cbc 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3770,7 +3770,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
mv88e6xxx_reg_unlock(chip);
/* Some internal PHYs don't have a model number. */
- if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
+ if (!err && reg == MII_PHYSID2 && !(val & 0x3f0) &&
chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
prod_id = family_prod_id_table[chip->info->family];
if (prod_id)
--
2.51.0
next reply other threads:[~2026-08-14 13:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 13:40 Ruoyu Wang [this message]
2026-08-14 14:18 ` [PATCH net] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260814134006.1386372-1-ruoyuw560@gmail.com \
--to=ruoyuw560@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox