]> git.ipfire.org Git - thirdparty/openwrt.git/commit
realtek: harden MDIO driver
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Fri, 2 May 2025 17:44:29 +0000 (13:44 -0400)
committerStijn Tintel <stijn@linux-ipv6.be>
Mon, 12 May 2025 13:09:19 +0000 (16:09 +0300)
commit47de87eb23c48315be208dad9995382208fad25f
tree8df0e8afefe042015bda2f228cc16b55ed16ac81
parent96ce4855bc8449b6afc31996c6b250199bbda7ae
realtek: harden MDIO driver

At least since 2022 there is a major bug in the MDIO driver that
produces out-of-bound reads and erratic behaviour during initialization.

- mdiobus_scan_bus_c22() scans the bus for 64 devices (PHY_MAX_ADDR)
- private bus structure only supports 57 entry arrays (MAX_PORTS)

All the bus/reader writer functions accept calls with addr>=57 and will
silently read beyond their limits. This can lead to ghost SERDES like
https://github.com/openwrt/openwrt/issues/18665#issuecomment-2846053813

Add proper boundary checks and end the functions with -ENODEV that is
the only accepted error code from the bus scan function.

Fixes: 0536c582e673aa292 ("realtek: Fix RTL931X Ethernet driver") etc ...
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/18402
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
target/linux/realtek/files-6.6/drivers/net/ethernet/rtl838x_eth.c