1 From d5d790ba1558dbb8d179054f514476e2ee970b8e Mon Sep 17 00:00:00 2001
2 From: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
3 Date: Thu, 9 Oct 2025 11:00:09 +0530
4 Subject: net: usb: lan78xx: Fix lost EEPROM write timeout error(-ETIMEDOUT) in lan78xx_write_raw_eeprom
6 From: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
8 commit d5d790ba1558dbb8d179054f514476e2ee970b8e upstream.
10 The function lan78xx_write_raw_eeprom failed to properly propagate EEPROM
11 write timeout errors (-ETIMEDOUT). In the timeout fallthrough path, it first
12 attempted to restore the pin configuration for LED outputs and then
13 returned only the status of that restore operation, discarding the
14 original timeout error saved in ret.
16 As a result, callers could mistakenly treat EEPROM write operation as
17 successful even though the EEPROM write had actually timed out with no
18 or partial data write.
20 To fix this, handle errors in restoring the LED pin configuration separately.
21 If the restore succeeds, return any prior EEPROM write timeout error saved
24 Suggested-by: Oleksij Rempel <o.rempel@pengutronix.de>
25 Fixes: 8b1b2ca83b20 ("net: usb: lan78xx: Improve error handling in EEPROM and OTP operations")
26 cc: stable@vger.kernel.org
27 Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
28 Reviewed-by: Simon Horman <horms@kernel.org>
29 Signed-off-by: David S. Miller <davem@davemloft.net>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 drivers/net/usb/lan78xx.c | 11 +++++++----
33 1 file changed, 7 insertions(+), 4 deletions(-)
35 --- a/drivers/net/usb/lan78xx.c
36 +++ b/drivers/net/usb/lan78xx.c
37 @@ -1174,10 +1174,13 @@ static int lan78xx_write_raw_eeprom(stru
40 write_raw_eeprom_done:
41 - if (dev->chipid == ID_REV_CHIP_ID_7800_)
42 - return lan78xx_write_reg(dev, HW_CFG, saved);
45 + if (dev->chipid == ID_REV_CHIP_ID_7800_) {
46 + int rc = lan78xx_write_reg(dev, HW_CFG, saved);
47 + /* If USB fails, there is nothing to do */
54 static int lan78xx_read_raw_otp(struct lan78xx_net *dev, u32 offset,