mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [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
  0 siblings, 1 reply; 2+ 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] 2+ 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
  0 siblings, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2026-11-15 18:24 UTC | newest]

Thread overview: 2+ 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

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®