net: usb: lan78xx: reject invalid EEPROM write requests
Subsystems (5)
PATCH v2 1/1 net: usb: lan78xx: reject invalid EEPROM write requests
The runtime PM handling removed the -EINVAL return for invalid EEPROM/OTP write requests. These requests now return zero from a successful usb_autopm_get_interface() call, even though no data is written.
Set ret to -EINVAL for invalid requests while preserving the runtime PM reference release.
---
Changes in v2:
- Add braces to all branches of the if/else chain as suggested by Andrew.
- Add Nicolai's Reviewed-by and Tested-by tags.
v1: https://lore.kernel.org/r/[email protected]
Tested on a Raspberry Pi 3 Model B+ with the onboard Ethernet controller, using raspberrypi/linux commit bba53a117a4a on the rpi-6.6.y branch as the baseline.
ethtool -E eth0 magic 0 offset 0 length 1 value 0
The command succeeds without the patch and reports "Invalid argument" with the patch applied.
--- drivers/net/usb/lan78xx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/usb/lan78xx.c +6 -3
@@ -1712,13 +1712,16 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,/* Invalid EEPROM_INDICATOR at offset zero will result in a failure * to load data from EEPROM */ -if (ee->magic ==LAN78XX_EEPROM_MAGIC ) +if (ee->magic ==LAN78XX_EEPROM_MAGIC ) { ret =lan78xx_write_raw_eeprom (dev, ee->offset, ee->len, data); -else if ((ee->magic ==LAN78XX_OTP_MAGIC ) && + }else if ((ee->magic ==LAN78XX_OTP_MAGIC ) && (ee->offset ==0 ) && (ee->len ==512 ) && - (data[0 ] ==OTP_INDICATOR_1 )) + (data[0 ] ==OTP_INDICATOR_1 )) { ret =lan78xx_write_raw_otp (dev, ee->offset, ee->len, data); + }else { + ret = -EINVAL ; + }usb_autopm_put_interface (dev->intf);
Signature · 1 line
2.55.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
The runtime PM handling removed the
-EINVALreturn for invalid EEPROM/OTP write requests. These requests now return zero from a successfulusb_autopm_get_interface()call, even though no data is written.Set ret to
-EINVALfor invalid requests while preserving the runtime PM reference release.Fixes 8a7ffeb795f8 ("lan78xx: Fix for eeprom read/write when device auto suspend")Signed-off-by Stefano Munari <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 7 lines
The runtime PM handling removed the
-EINVALreturn for invalid EEPROM/OTP write requests. These requests now return zero from a successfulusb_autopm_get_interface()call, even though no data is written.Set ret to
-EINVALfor invalid requests while preserving the runtime PM reference release.
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Sat, 10 Oct 2026 23:32:48 +0200 you wrote:
The runtime PM handling removed the
-EINVALreturn for invalid EEPROM/OTP write requests. These requests now return zero from a successfulusb_autopm_get_interface()call, even though no data is written.Set ret to
-EINVALfor invalid requests while preserving the runtime PM reference release.[...]
Here is the summary with links:
- [net,v2] net: usb: lan78xx: reject invalid EEPROM write requests
https://git.kernel.org/netdev/net-next/c/9272297df141
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html