net: usb: lan78xx: Fix lost EEPROM write timeout error(-ETIMEDOUT) in lan78xx_write_raw_eeprom
Subsystems (6)
PATCH 1/1 net: usb: lan78xx: Fix lost EEPROM write timeout error(-ETIMEDOUT) in lan78xx_write_raw_eeprom
The function lan78xx_write_raw_eeprom failed to properly propagate EEPROM write timeout errors (-ETIMEDOUT). In the timeout fallthrough path, it first attempted to restore the pin configuration for LED outputs and then returned only the status of that restore operation, discarding the original timeout error saved in ret.
As a result, callers could mistakenly treat EEPROM write operation as successful even though the EEPROM write had actually timed out with no or partial data write.
To fix this, handle errors in restoring the LED pin configuration separately. If the restore succeeds, return any prior EEPROM write timeout error saved in ret to the caller.
---
Note:
The patch is compiled and tested using EVB-LAN7800LC.
The patch was suggested by Oleksij Rempel while reviewing a fix to a bug found by syzbot earlier.
The review mail chain where this fix was suggested is given below.
https://lore.kernel.org/all/[email protected]/
ChangeLog:
v1->v2:
Added cc:stable tag as asked during v1 review.
V1 Link : https://lore.kernel.org/all/[email protected]/
drivers/net/usb/lan78xx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/usb/lan78xx.c +7 -4
@@ -1174,10 +1174,13 @@ static int lan78xx_write_raw_eeprom(struct lan78xx_net *dev, u32 offset, } write_raw_eeprom_done: -if (dev->chipid ==ID_REV_CHIP_ID_7800_ ) -return lan78xx_write_reg (dev,HW_CFG , saved); - -return 0 ; +if (dev->chipid ==ID_REV_CHIP_ID_7800_ ) { +int rc =lan78xx_write_reg (dev,HW_CFG , saved); +/* If USB fails, there is nothing to do */ +if (rc <0 ) +return rc; + } +return ret; } static int lan78xx_read_raw_otp(struct lan78xx_net *dev, u32 offset,
Signature · 1 line
2.34.1
Quoted 46 lines · Bhanu Seshu Kumar Valluri
The function
lan78xx_write_raw_eepromfailed to properly propagate EEPROM write timeout errors (-ETIMEDOUT). In the timeout fallthrough path, it first attempted to restore the pin configuration for LED outputs and then returned only the status of that restore operation, discarding the original timeout error saved in ret.As a result, callers could mistakenly treat EEPROM write operation as successful even though the EEPROM write had actually timed out with no or partial data write.
To fix this, handle errors in restoring the LED pin configuration separately. If the restore succeeds, return any prior EEPROM write timeout error saved in ret to the caller.
Suggested-by Oleksij Rempel <[email protected]>Fixes 8b1b2ca83b20 ("net: usb: lan78xx: Improve error handling in EEPROM and OTP operations")Signed-off-by Bhanu Seshu Kumar Valluri <[email protected]>---
Note:
The patch is compiled and tested using EVB-LAN7800LC.
The patch was suggested by Oleksij Rempel while reviewing a fix to a bug found by syzbot earlier.
The review mail chain where this fix was suggested is given below.
https://lore.kernel.org/all/[email protected]/ChangeLog:
v1->v2:
Added cc:stable tag as asked during v1 review.
V1 Link : https://lore.kernel.org/all/[email protected]/drivers/net/usb/lan78xx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/net/usb/lan78xx.c +0
-4@@ -1174,10 +1174,13 @@ static int lan78xx_write_raw_eeprom(struct lan78xx_net *dev, u32 offset, } write_raw_eeprom_done: -if (dev->chipid ==ID_REV_CHIP_ID_7800_ ) -return lan78xx_write_reg (dev,HW_CFG , saved); - -return 0 ;
drivers/net/usb/lan78xx.c static int lan78xx_write_raw_eeprom(struct lan78xx_net *dev, u32 offset, · line 1186
Quoted 10 lines
drivers/net/usb/lan78xx.c +7
-0+if (dev->chipid ==ID_REV_CHIP_ID_7800_ ) { +int rc =lan78xx_write_reg (dev,HW_CFG , saved); +/* If USB fails, there is nothing to do */ +if (rc <0 ) +return rc; + } +return ret; } static int lan78xx_read_raw_otp(struct lan78xx_net *dev, u32 offset,
Hi,
The subject prefix must be [PATCH v2] instead. I overlooked it. Should I resend it?
Regards,
Bhanu Seshu Kumar Valluri
Paolo Abeni
maintainerHello,
Quoted 56 lines · Bhanu Seshu Kumar Valluri
Quoted 55 lines · Bhanu Seshu Kumar Valluri
The function
lan78xx_write_raw_eepromfailed to properly propagate EEPROM write timeout errors (-ETIMEDOUT). In the timeout fallthrough path, it first attempted to restore the pin configuration for LED outputs and then returned only the status of that restore operation, discarding the original timeout error saved in ret.As a result, callers could mistakenly treat EEPROM write operation as successful even though the EEPROM write had actually timed out with no or partial data write.
To fix this, handle errors in restoring the LED pin configuration separately. If the restore succeeds, return any prior EEPROM write timeout error saved in ret to the caller.
Suggested-by Oleksij Rempel <[email protected]>Fixes 8b1b2ca83b20 ("net: usb: lan78xx: Improve error handling in EEPROM and OTP operations")Signed-off-by Bhanu Seshu Kumar Valluri <[email protected]>---
Note:
The patch is compiled and tested using EVB-LAN7800LC.
The patch was suggested by Oleksij Rempel while reviewing a fix to a bug found by syzbot earlier.
The review mail chain where this fix was suggested is given below.
https://lore.kernel.org/all/[email protected]/ChangeLog:
v1->v2:
Added cc:stable tag as asked during v1 review.
V1 Link : https://lore.kernel.org/all/[email protected]/drivers/net/usb/lan78xx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/net/usb/lan78xx.c +7
-4@@ -1174,10 +1174,13 @@ static int lan78xx_write_raw_eeprom(struct lan78xx_net *dev, u32 offset, } write_raw_eeprom_done: -if (dev->chipid ==ID_REV_CHIP_ID_7800_ ) -return lan78xx_write_reg (dev,HW_CFG , saved); - -return 0 ; +if (dev->chipid ==ID_REV_CHIP_ID_7800_ ) { +int rc =lan78xx_write_reg (dev,HW_CFG , saved); +/* If USB fails, there is nothing to do */ +if (rc <0 ) +return rc; + } +return ret; }
Quoted 5 lines
drivers/net/usb/lan78xx.c static int lan78xx_write_raw_eeprom(struct lan78xx_net *dev, u32 offset, · line 1186
Quoted 1 line
drivers/net/usb/lan78xx.c +0
-0static int lan78xx_read_raw_otp(struct lan78xx_net *dev, u32 offset,Hi,
The subject prefix must be [PATCH v2] instead. I overlooked it. Should I resend it?
This is not a review, and given the current amount of queued patches a real one will not follow soon, but please do not send a new version just for this.
Thanks,
Paolo
Quoted 26 lines · Bhanu Seshu Kumar Valluri
The function
lan78xx_write_raw_eepromfailed to properly propagate EEPROM write timeout errors (-ETIMEDOUT). In the timeout fallthrough path, it first attempted to restore the pin configuration for LED outputs and then returned only the status of that restore operation, discarding the original timeout error saved in ret.As a result, callers could mistakenly treat EEPROM write operation as successful even though the EEPROM write had actually timed out with no or partial data write.
To fix this, handle errors in restoring the LED pin configuration separately. If the restore succeeds, return any prior EEPROM write timeout error saved in ret to the caller.
Suggested-by Oleksij Rempel <[email protected]>Fixes 8b1b2ca83b20 ("net: usb: lan78xx: Improve error handling in EEPROM and OTP operations")Signed-off-by Bhanu Seshu Kumar Valluri <[email protected]>---
Note:
The patch is compiled and tested using EVB-LAN7800LC.
The patch was suggested by Oleksij Rempel while reviewing a fix to a bug found by syzbot earlier.
The review mail chain where this fix was suggested is given below.
https://lore.kernel.org/all/[email protected]/
Quoted 4 lines
ChangeLog:
v1->v2:
Added cc:stable tag as asked during v1 review.
V1 Link : https://lore.kernel.org/all/[email protected]/
Thanks,
This patch seems consistent with the discussion at the link under Note. I believe it addresses the review of v1.
And that the Fixes tag corresponds to the commit that introduced this problem.
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 11 lines · On Thu, 9 Oct 2025 11:00:09 +0530 you wrote:
The function
lan78xx_write_raw_eepromfailed to properly propagate EEPROM write timeout errors (-ETIMEDOUT). In the timeout fallthrough path, it first attempted to restore the pin configuration for LED outputs and then returned only the status of that restore operation, discarding the original timeout error saved in ret.As a result, callers could mistakenly treat EEPROM write operation as successful even though the EEPROM write had actually timed out with no or partial data write.
[...]
Here is the summary with links:
- net: usb: lan78xx: Fix lost EEPROM write timeout error(-ETIMEDOUT) in lan78xx_write_raw_eeprom
https://git.kernel.org/netdev/net/c/d5d790ba1558
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html