Skip to content

Commit d5d790b

Browse files
bhanuseshukumardavem330
authored andcommitted
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. Suggested-by: Oleksij Rempel <o.rempel@pengutronix.de> Fixes: 8b1b2ca ("net: usb: lan78xx: Improve error handling in EEPROM and OTP operations") cc: stable@vger.kernel.org Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f3426ac commit d5d790b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

drivers/net/usb/lan78xx.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,10 +1175,13 @@ static int lan78xx_write_raw_eeprom(struct lan78xx_net *dev, u32 offset,
11751175
}
11761176

11771177
write_raw_eeprom_done:
1178-
if (dev->chipid == ID_REV_CHIP_ID_7800_)
1179-
return lan78xx_write_reg(dev, HW_CFG, saved);
1180-
1181-
return 0;
1178+
if (dev->chipid == ID_REV_CHIP_ID_7800_) {
1179+
int rc = lan78xx_write_reg(dev, HW_CFG, saved);
1180+
/* If USB fails, there is nothing to do */
1181+
if (rc < 0)
1182+
return rc;
1183+
}
1184+
return ret;
11821185
}
11831186

11841187
static int lan78xx_read_raw_otp(struct lan78xx_net *dev, u32 offset,

0 commit comments

Comments
 (0)