* [PATCH net-next v2] net: phy: et1011c: don't write an error code to the config register
@ 2026-11-15 18:07 Elias Pukari
2026-11-15 18:24 ` Andrew Lunn
2026-11-16 18:59 ` netdev-bot+sashiko
0 siblings, 2 replies; 3+ messages in thread
From: Elias Pukari @ 2026-11-15 18:07 UTC (permalink / raw)
To: netdev
Cc: Elias Pukari, Andrew Lunn, Heiner Kallweit, Russell King,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel
phy_read() can return a negative error code. Use an int and check
both reads before using their results.
Found with LLM help; fake-MDIO KUnit error-injection tests passed
(6/6, KASAN). No hardware testing.
Signed-off-by: Elias Pukari <elias.pukari@gmail.com>
---
v2: Drop Fixes and shorten the commit message; no code changes.
v1: https://lore.kernel.org/netdev/20261113221917.3542509-1-elias.pukari@gmail.com/
drivers/net/phy/et1011c.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/et1011c.c b/drivers/net/phy/et1011c.c
index 6cd8d7758..603fe5a1e 100644
--- a/drivers/net/phy/et1011c.c
+++ b/drivers/net/phy/et1011c.c
@@ -62,16 +62,22 @@ static int et1011c_read_status(struct phy_device *phydev)
{
static int speed;
int ret;
- u32 val;
+ int val;
ret = genphy_read_status(phydev);
if (speed != phydev->speed) {
speed = phydev->speed;
val = phy_read(phydev, ET1011C_STATUS_REG);
+ if (val < 0)
+ return val;
+
if ((val & ET1011C_SPEED_MASK) ==
ET1011C_GIGABIT_SPEED) {
val = phy_read(phydev, ET1011C_CONFIG_REG);
+ if (val < 0)
+ return val;
+
val &= ~ET1011C_TX_FIFO_MASK;
phy_write(phydev, ET1011C_CONFIG_REG, val |
ET1011C_GMII_INTERFACE |
base-commit: d1f4b7c6b997c29de67ad7178ababac2328cb1b4
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next v2] net: phy: et1011c: don't write an error code to the config register
2026-11-15 18:07 [PATCH net-next v2] net: phy: et1011c: don't write an error code to the config register Elias Pukari
@ 2026-11-15 18:24 ` Andrew Lunn
2026-11-16 18:59 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2026-11-15 18:24 UTC (permalink / raw)
To: Elias Pukari
Cc: netdev, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
On Sun, Nov 15, 2026 at 08:07:35PM +0200, Elias Pukari wrote:
> phy_read() can return a negative error code. Use an int and check
> both reads before using their results.
>
> Found with LLM help; fake-MDIO KUnit error-injection tests passed
> (6/6, KASAN). No hardware testing.
> Signed-off-by: Elias Pukari <elias.pukari@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next v2] net: phy: et1011c: don't write an error code to the config register
2026-11-15 18:07 [PATCH net-next v2] net: phy: et1011c: don't write an error code to the config register Elias Pukari
2026-11-15 18:24 ` Andrew Lunn
@ 2026-11-16 18:59 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-16 18:59 UTC (permalink / raw)
To: elias.pukari
Cc: netdev, andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
linux-kernel
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] net: phy: et1011c: premature speed update in
et1011c_read_status()
--
> diff --git a/drivers/net/phy/et1011c.c b/drivers/net/phy/et1011c.c
> --- a/drivers/net/phy/et1011c.c
> +++ b/drivers/net/phy/et1011c.c
> @@ -62,16 +62,22 @@ static int et1011c_read_status(struct phy_device *phydev)
> {
> static int speed;
> int ret;
> - u32 val;
> + int val;
>
> ret = genphy_read_status(phydev);
>
> if (speed != phydev->speed) {
> speed = phydev->speed;
> val = phy_read(phydev, ET1011C_STATUS_REG);
> + if (val < 0)
> + return val;
> +
> if ((val & ET1011C_SPEED_MASK) ==
> ET1011C_GIGABIT_SPEED) {
> val = phy_read(phydev, ET1011C_CONFIG_REG);
> + if (val < 0)
> + return val;
> +
> val &= ~ET1011C_TX_FIFO_MASK;
> phy_write(phydev, ET1011C_CONFIG_REG, val |
> ET1011C_GMII_INTERFACE |
>
>
[Severity: Medium]
With the new early returns, et1011c_read_status() updates the static
speed cache to phydev->speed before either phy_read() is attempted.
Suppose the read of ET1011C_STATUS_REG or ET1011C_CONFIG_REG fails
while the link comes up at 1000Mbps. We return the error without
programming ET1011C_CONFIG_REG, but speed already equals
phydev->speed. On the next poll the speed != phydev->speed test is
false, so the block is skipped. ET1011C_GMII_INTERFACE,
ET1011C_SYS_CLK_EN and ET1011C_TX_FIFO_DEPTH_16 are then never applied
for that gigabit link.
The error path in _phy_state_machine() does not help either. Entering
PHY_ERROR clears phydev->link but leaves phydev->speed alone, so a link
that comes back at the same speed will not retrigger the write.
Could speed be updated only after the reads (and ideally the
phy_write()) have succeeded, so that a transient MDIO error is retried
on the next poll? Or is there a reason the cache has to be set before
the register accesses?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115180735.649299-1-elias.pukari%40gmail.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-16 18:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 18:07 [PATCH net-next v2] net: phy: et1011c: don't write an error code to the config register Elias Pukari
2026-11-15 18:24 ` Andrew Lunn
2026-11-16 18:59 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®