net: usb: lan78xx: Fix lost EEPROM write timeout error(-ETIMEDOUT) in lan78xx_write_raw_eeprom
Subsystems (5)
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.
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]/
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
Greg KH
maintainerQuoted 54 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.
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]/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
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.
You are receiving this message because of the following common error(s) as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this.
If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.
thanks,
greg k-h's patch email bot
Quoted 40 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.
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]/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,
You were able to test the change to read eeprom code by forcing a timeout while doing probe on EVB-LAN7800LC. Were you able to test this code change the same way just to make sure callers of the write function handle the new ETIMEDOUT return value correctly?
Thanks,
Khalid
Quoted 52 lines · Khalid Aziz
Quoted 40 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.
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]/
drivers/net/usb/lan78xx.c| 11 +++++++----1 file changed, 7 insertions(+), 4 deletions(-)drivers/net/usb/lan78xx.c +0
-0@@ -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_) - returnlan78xx_write_reg(dev, HW_CFG, saved); -
- return 0;
+ if (dev->chipid==ID_REV_CHIP_ID_7800_) {Quoted 8 lines
+ 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(structlan78xx_net*dev, u32 offset,You were able to test the change to read eeprom code by forcing a timeout while doing probe on EVB-LAN7800LC. Were you able to test this code change the same way just to make sure callers of the write function handle the new ETIMEDOUT return value correctly?
Quoted 1 line
Thanks,
Hi Khalid,
This function is only invoked from user's ethtool operations. The ethtool handles errors returned from the driver callback functions. I tested it with ethtool -E option by forcing a ETIMEDOUT error early in the lan78xx_write_raw_eeprom temporarily. The ethtool reported error with "Cannot set EEPROM data" message. The ethtool version used is 5.16.
Regards,
Bhanu Seshu Kumar Valluri
Quoted 13 lines · Greg KH
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.
You are receiving this message because of the following common error(s) as indicated below:
Quoted 8 lines
- You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the
Documentation/process/stable-kernel-rules.rstfile for how to resolve this.
Hi,
Sent a v2 with cc: stable tag.
v2 Link https://lore.kernel.org/all/[email protected]/
Regards,
Bhanu Seshu Kumar Valluri