* [PATCH net] net: usb: lan78xx: reject invalid EEPROM write requests
@ 2026-10-09 0:57 Stefano Munari
2026-10-09 1:02 ` sashiko-bot
2026-10-09 1:27 ` Andrew Lunn
0 siblings, 2 replies; 4+ messages in thread
From: Stefano Munari @ 2026-10-09 0:57 UTC (permalink / raw)
To: netdev
Cc: Thangaraj Samynathan, UNGLinuxDriver, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Nisar Sayed, linux-usb, linux-kernel
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.
Fixes: 8a7ffeb795f8 ("lan78xx: Fix for eeprom read/write when device auto suspend")
Signed-off-by: Stefano Munari <stefanomunari.sm@gmail.com>
---
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 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 5655941f1478..7ac263454d45 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1719,6 +1719,8 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
(ee->len == 512) &&
(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);
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] net: usb: lan78xx: reject invalid EEPROM write requests
2026-10-09 0:57 [PATCH net] net: usb: lan78xx: reject invalid EEPROM write requests Stefano Munari
@ 2026-10-09 1:02 ` sashiko-bot
2026-10-09 1:27 ` Andrew Lunn
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-10-09 1:02 UTC (permalink / raw)
To: Stefano Munari; +Cc: linux-usb
> 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.
>
> Fixes: 8a7ffeb795f8 ("lan78xx: Fix for eeprom read/write when device auto suspend")
> Signed-off-by: Stefano Munari <stefanomunari.sm@gmail.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009005702.164936-1-stefanomunari.sm@gmail.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] net: usb: lan78xx: reject invalid EEPROM write requests
2026-10-09 0:57 [PATCH net] net: usb: lan78xx: reject invalid EEPROM write requests Stefano Munari
2026-10-09 1:02 ` sashiko-bot
@ 2026-10-09 1:27 ` Andrew Lunn
2026-10-09 8:28 ` Nicolai Buchwitz
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2026-10-09 1:27 UTC (permalink / raw)
To: Stefano Munari
Cc: netdev, Thangaraj Samynathan, UNGLinuxDriver, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Nisar Sayed, linux-usb, linux-kernel
On Fri, Oct 09, 2026 at 02:57:02AM +0200, Stefano Munari wrote:
> 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.
>
> Fixes: 8a7ffeb795f8 ("lan78xx: Fix for eeprom read/write when device auto suspend")
> Signed-off-by: Stefano Munari <stefanomunari.sm@gmail.com>
> ---
> 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 | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 5655941f1478..7ac263454d45 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1719,6 +1719,8 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
> (ee->len == 512) &&
> (data[0] == OTP_INDICATOR_1))
> ret = lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
> + else
> + ret = -EINVAL;
It might be the nested if's without {} which caused the broken patch?
Maybe add some brackets to make it clearer?
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] net: usb: lan78xx: reject invalid EEPROM write requests
2026-10-09 1:27 ` Andrew Lunn
@ 2026-10-09 8:28 ` Nicolai Buchwitz
0 siblings, 0 replies; 4+ messages in thread
From: Nicolai Buchwitz @ 2026-10-09 8:28 UTC (permalink / raw)
To: Andrew Lunn
Cc: Stefano Munari, netdev, Thangaraj Samynathan, UNGLinuxDriver,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Nisar Sayed, linux-usb, linux-kernel
On 9.10.2026 03:27, Andrew Lunn wrote:
> On Fri, Oct 09, 2026 at 02:57:02AM +0200, Stefano Munari wrote:
>> 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.
>>
>> Fixes: 8a7ffeb795f8 ("lan78xx: Fix for eeprom read/write when device
>> auto suspend")
>> Signed-off-by: Stefano Munari <stefanomunari.sm@gmail.com>
>> ---
>> 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 | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
>> index 5655941f1478..7ac263454d45 100644
>> --- a/drivers/net/usb/lan78xx.c
>> +++ b/drivers/net/usb/lan78xx.c
>> @@ -1719,6 +1719,8 @@ static int lan78xx_ethtool_set_eeprom(struct
>> net_device *netdev,
>> (ee->len == 512) &&
>> (data[0] == OTP_INDICATOR_1))
>> ret = lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
>> + else
>> + ret = -EINVAL;
>
> It might be the nested if's without {} which caused the broken patch?
>
> Maybe add some brackets to make it clearer?
>
> Andrew
8a7ffeb795f8 dropped the final return -EINVAL when it converted the
returns to ret = ..., braces wouldn't have caught that. Fine with
adding them for a v2 though.
In either case:
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Tested-by: Nicolai Buchwitz <nb@tipi-net.de> # Raspberry Pi 3B+
(LAN7515)
Thanks,
Nicolai
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-09 8:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-09 0:57 [PATCH net] net: usb: lan78xx: reject invalid EEPROM write requests Stefano Munari
2026-10-09 1:02 ` sashiko-bot
2026-10-09 1:27 ` Andrew Lunn
2026-10-09 8:28 ` Nicolai Buchwitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox