* [PATCH net-next v2] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error
@ 2026-08-15 15:17 Ruoyu Wang
2026-08-20 11:49 ` Paolo Abeni
0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-08-15 15:17 UTC (permalink / raw)
To: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Ruoyu Wang
mv88e6xxx_mdio_read() applies the internal PHY model-number workaround
before returning a Clause 22 read error. Since the PHY read may leave
val untouched on failure, the workaround can consume an uninitialized
value.
Return the PHY read error immediately after dropping the register lock.
Successful reads continue through the workaround and return val as
before.
This issue was found by a static analysis checker and confirmed by
manual source review.
Assisted-by: unnamed:deepseek-v4-pro typestate
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
Changes in v2:
- Return immediately on PHY read errors.
- Target net-next and drop the Fixes tag, as requested.
- Add the Assisted-by tag.
v1: https://lore.kernel.org/r/20260814134006.1386372-1-ruoyuw560@gmail.com/
---
drivers/net/dsa/mv88e6xxx/chip.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 80b877c74513d6..432285e2881715 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3769,6 +3769,9 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
mv88e6xxx_reg_unlock(chip);
+ if (err)
+ return err;
+
/* Some internal PHYs don't have a model number. */
if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
@@ -3777,7 +3780,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
val |= prod_id >> 4;
}
- return err ? err : val;
+ return val;
}
static int mv88e6xxx_mdio_read_c45(struct mii_bus *bus, int phy, int devad,
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error
2026-08-15 15:17 [PATCH net-next v2] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error Ruoyu Wang
@ 2026-08-20 11:49 ` Paolo Abeni
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2026-08-20 11:49 UTC (permalink / raw)
To: Ruoyu Wang, Andrew Lunn, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski
Cc: netdev, linux-kernel
On 8/15/26 5:17 PM, Ruoyu Wang wrote:
> mv88e6xxx_mdio_read() applies the internal PHY model-number workaround
> before returning a Clause 22 read error. Since the PHY read may leave
> val untouched on failure, the workaround can consume an uninitialized
> value.
>
> Return the PHY read error immediately after dropping the register lock.
> Successful reads continue through the workaround and return val as
> before.
>
> This issue was found by a static analysis checker and confirmed by
> manual source review.
>
> Assisted-by: unnamed:deepseek-v4-pro typestate
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
## Form letter - net-next-closed
We have already submitted our pull request with net-next material for v7.3,
and therefore net-next is closed for new drivers, features, code refactoring
and optimizations. We are currently accepting bug fixes only.
Please repost when net-next reopens after Aug 31st.
RFC patches sent for review only are obviously welcome at any time.
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-20 11:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-15 15:17 [PATCH net-next v2] net: dsa: mv88e6xxx: Avoid uninitialized value on MDIO read error Ruoyu Wang
2026-08-20 11:49 ` Paolo Abeni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox