net: phy: realtek: fix listing of sysfs directory tree
Subsystems (4)
PATCH 1/1 net: phy: realtek: fix listing of sysfs directory tree
On git master, listing the contents of sysfs produces an error:
root@mateusz-debian:/sys# LANG=C find -iname foobar find: './module/realtek/drivers': Input/output error root@mateusz-debian:/sys# LANG=C ls -1 ./module/realtek/drivers ls: reading directory './module/realtek/drivers': Input/output error 'mdio_bus:Generic FE-GE Realtek PHY' 'mdio_bus:RTL8201CP Ethernet' 'mdio_bus:RTL8201F Fast Ethernet' 'mdio_bus:RTL8208 Fast Ethernet' 'mdio_bus:RTL8211B Gigabit Ethernet' [...]
Investigation shows that the forward slash in the driver name is the culprit. Fix it.
--- drivers/net/phy/realtek/realtek_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/realtek/realtek_main.c +1 -1
@@ -3483,7 +3483,7 @@ static struct phy_driver realtek_drvs[] = { .write_mmd = genphy_write_mmd_unsupported, }, { PHY_ID_MATCH_EXACT(RTL_8261C_CG), - .name = "Realtek RTL8261C/D 10Gbps PHY", + .name = "Realtek RTL8261C_RTL8261D 10Gbps PHY", .probe = rtl8261x_probe, .config_init = rtl8261x_config_init, .get_features = rtl8261x_get_features,
Signature · 1 line
2.47.3
Quoted 13 lines · Mateusz Jończyk
On git master, listing the contents of sysfs produces an error:
root@mateusz-debian:/sys# LANG=C find -iname foobar find: './module/realtek/drivers': Input/output error root@mateusz-debian:/sys# LANG=C ls -1 ./module/realtek/drivers ls: reading directory './module/realtek/drivers': Input/output error 'mdio_bus:Generic FE-GE Realtek PHY' 'mdio_bus:RTL8201CP Ethernet' 'mdio_bus:RTL8201F Fast Ethernet' 'mdio_bus:RTL8208 Fast Ethernet' 'mdio_bus:RTL8211B Gigabit Ethernet' [...]
Quoted 6 lines
Investigation shows that the forward slash in the driver name is the culprit. Fix it.
Fixes f0667918d5fc ("net: phy: realtek: add support for RTL8261D")Signed-off-by Mateusz Jończyk <[email protected]>
Andrew
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [High] The patch renames one Realtek PHY driver ("Realtek RTL8261C/D 10Gbps PHY" -> "Realtek RTL8261C_RTL8261D 10Gbps PHY" in realtek_drvs,…
--
net: phy: realtek: fix listing of sysfs directory tree
This commit renames the RTL8261C/D PHY driver from "Realtek RTL8261C/D 10Gbps PHY" to "Realtek RTL8261C_RTL8261D 10Gbps PHY". The '/' in the old name makes reading /sys/module/realtek/drivers fail with EIO. It is tagged for stable.
drivers/net/phy/realtek/realtek_main.c static struct phy_driver realtek_drvs[] = { · line 3486
Quoted 10 lines
drivers/net/phy/realtek/realtek_main.c +1
-1@@ -3483,7 +3483,7 @@ static struct phy_driver realtek_drvs[] = { .write_mmd = genphy_write_mmd_unsupported, }, { PHY_ID_MATCH_EXACT(RTL_8261C_CG), - .name = "Realtek RTL8261C/D 10Gbps PHY", + .name = "Realtek RTL8261C_RTL8261D 10Gbps PHY",
[Severity: High]
This fixes one driver, but does it leave the root cause in place?
The symlink name under /sys/module/<mod>/drivers is built from the raw driver name in make_driver_name():
drivers/base/module.c:make_driver_name() {
driver_name = kasprintf(GFP_KERNEL, "%s:%s", drv->bus->name, drv->name);
...
}module_add_driver() then creates the link under that name:
ret = sysfs_create_link(mk->drivers_dir, &drv->p->kobj, driver_name);
kernfs accepts the '/'. When the directory is read, verify_dirent_name() in fs/readdir.c rejects the name and getdents fails for the whole directory:
if (memchr(name, '/', len)) return -EIO;
The driver kobject itself is not affected, because kobject_set_name_vargs() already does strreplace(t, '/', '!'). Only the module drivers symlink name skips that replacement.
At this commit, several other tristate PHY drivers still have '/' in their names:
drivers/net/phy/smsc.c: "SMSC LAN8710/LAN8720" drivers/net/phy/qcom/at803x.c: "Qualcomm Atheros AR8031/AR8033" drivers/net/phy/marvell.c: "Marvell 88E308X/88E609X Family" drivers/net/phy/davicom.c: "Davicom DM9161B/C" drivers/net/phy/intel-xway.c: "Intel XWAY PHY11G (PEF 7071/PEF 7072) v1.3"
(plus three more entries in the same file)
drivers/net/phy/microchip_t1s.c: "LAN865X Rev.B0/B1 Internal Phy" drivers/net/phy/xpowers/acx00.c: "X-Powers AC200/AC300 EPHY"
If any of these is built as a module and loaded, find /sys and ls /sys/module/<mod>/drivers should still fail with EIO. That is the same symptom quoted in the commit message.
Could the '/' be replaced in make_driver_name() instead, the same way kobject_set_name_vargs() does it? That would fix every bus and any future driver name. It would also avoid renaming the user-visible /sys/bus/mdio_bus/drivers/ entry for this PHY in a stable backport.
Quoted 3 lines
drivers/net/phy/realtek/realtek_main.c +0
-0.probe = rtl8261x_probe, .config_init = rtl8261x_config_init, .get_features = rtl8261x_get_features,
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115214045.3704-1-mat.jonczyk%40o2.pl
Andrew Lunn
maintainerQuoted 14 lines
[Severity: High]
This fixes one driver, but does it leave the root cause in place?
The symlink name under /sys/module/<mod>/drivers is built from the raw driver name in
make_driver_name():drivers/base/module.c:make_driver_name() { driver_name = kasprintf(GFP_KERNEL, "%s:%s", drv->bus->name, drv->name); ... }
module_add_driver()then creates the link under that name:
Quoted 9 lines
ret = sysfs_create_link(mk->drivers_dir, &drv->p->kobj, driver_name);kernfs accepts the '/'. When the directory is read,
verify_dirent_name()infs/readdir.crejects the name and getdents fails for the whole directory:if (memchr(name, '/', len)) return -EIO;
This is a kernel wide problem, so i don't think this patch needs to address it.
Quoted 8 lines
drivers/net/phy/smsc.c: "SMSC LAN8710/LAN8720"drivers/net/phy/qcom/at803x.c: "Qualcomm Atheros AR8031/AR8033"drivers/net/phy/marvell.c: "Marvell 88E308X/88E609X Family"drivers/net/phy/davicom.c: "Davicom DM9161B/C"drivers/net/phy/intel-xway.c: "Intel XWAY PHY11G (PEF 7071/PEF 7072) v1.3"
(plus three more entries in the same file)
drivers/net/phy/microchip_t1s.c: "LAN865X Rev.B0/B1 Internal Phy"drivers/net/phy/xpowers/acx00.c: "X-Powers AC200/AC300 EPHY"
Maybe turn this into a patch series and address all these, one patch each. That way, if we have any ABI issues, it is easy to revert just one driver.
Andrew
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 13 lines · On Sun, 15 Nov 2026 22:40:45 +0100 you wrote:
On git master, listing the contents of sysfs produces an error:
root@mateusz-debian:/sys# LANG=C find -iname foobar find: './module/realtek/drivers': Input/output error root@mateusz-debian:/sys# LANG=C ls -1 ./module/realtek/drivers ls: reading directory './module/realtek/drivers': Input/output error 'mdio_bus:Generic FE-GE Realtek PHY' 'mdio_bus:RTL8201CP Ethernet' 'mdio_bus:RTL8201F Fast Ethernet' 'mdio_bus:RTL8208 Fast Ethernet' 'mdio_bus:RTL8211B Gigabit Ethernet' [...]
Quoted 1 line
[...]
Here is the summary with links:
- net: phy: realtek: fix listing of sysfs directory tree
https://git.kernel.org/netdev/net/c/f16d85cd3de9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html