Re: [PATCH net v4 1/2] net: usb: lan78xx: do not update statistics after a failed read
From: Andrew Lunn
Date: Mon Oct 19 2026 - 20:37:54 EST
On Tue, Oct 20, 2026 at 08:16:20AM +0800, Wei Jie Law wrote:
> lan78xx_update_stats() reads the hardware counters into an on-stack
> struct lan78xx_statstage. If lan78xx_read_stats() fails, only the
> rollover check is skipped: the counters are still recomputed from the
> uninitialized stack buffer and stored in dev->stats.curr_stat, which is
> then reported to user space by ethtool -S.
>
> Keep the previous values when the read fails.
>
> Found by code review with LLM assistance. Tested together with the next
> patch, which makes short reads fail: with an emulated device, ethtool -S
> then keeps reporting the previous counters.
>
> Fixes: 20ff55655a93 ("lan78xx: handle statistics counter rollover")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Wei Jie Law <law.wei.jie@xxxxxxxxxxxxxx>
net-next please.
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
Reviewed-by: Andrew Lunn <andrew@xxxxxxx>
Andrew