* [PATCH net] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error
@ 2026-08-14 13:40 Ruoyu Wang
2026-08-14 14:18 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-08-14 13:40 UTC (permalink / raw)
To: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Vivien Didelot, Florian Fainelli
Cc: netdev, linux-kernel, Ruoyu Wang
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error
2026-08-14 13:40 [PATCH net] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error Ruoyu Wang
@ 2026-08-14 14:18 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2026-08-14 14:18 UTC (permalink / raw)
To: Ruoyu Wang
Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Vivien Didelot, Florian Fainelli, netdev,
linux-kernel
On Fri, Aug 14, 2026 at 09:40:06PM +0800, Ruoyu Wang wrote:
> 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)
Ugly.
Please do the usual for checking for errors and returning.
Also, this is not worthy of stable, please drop the Fixes tag, and
post to net-next.
Andrew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-14 14:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 13:40 [PATCH net] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error Ruoyu Wang
2026-08-14 14:18 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox