Thread View: linux.kernel.netdev
6 messages
6 total messages
Started by Prashant Sengar
Mon, 19 Oct 2026 19:31
[PATCH net v2] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
Author: Prashant Sengar
Date: Mon, 19 Oct 2026 19:31
Date: Mon, 19 Oct 2026 19:31
45 lines
12094 bytes
12094 bytes
LAN7801 supports fixed-link configurations without an attached PHY.
However, lan78xx_set_wol() unconditionally passes netdev->phydev
to phy_ethtool_set_wol(), causing a NULL pointer dereference when
a userspace WoL request reaches this path.
Use phylink_expects_phy() to skip PHY WoL configuration for fixed
links, and use phylink_ethtool_set_wol() for configurations that
expect a PHY. This avoids the NULL dereference while keeping PHY
operations within the phylink API.
The issue was reproduced using USB Raw Gadget and dummy_hcd in QEMU.
An ETHTOOL_SWOL ioctl triggered a kernel Oops with the original
driver. With this change, the same request completes successfully.
Fixes: e110bc825897 ("net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management")
Signed-off-by: Prashant Sengar <prashantsengar25031@gmail.com>
---
v2:
- Use phylink_expects_phy() to avoid PHY WoL operations for
fixed-link configurations.
- Use phylink_ethtool_set_wol() instead of the direct PHY
helper, addressing Andrew Lunn's review.
- Preserve the existing controller WoL configuration order.
v1: https://lore.kernel.org/netdev/20261018151830.643511-1-prashantsengar25031@gmail.com/
drivers/net/usb/lan78xx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 5655941f1478..1702f633d42e 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1805,7 +1805,9 @@ static int lan78xx_set_wol(struct net_device *netdev,
if (ret < 0)
goto exit_pm_put;
- ret = phy_ethtool_set_wol(netdev->phydev, wol);
+ if (phylink_expects_phy(dev->phylink))
+ ret = phylink_ethtool_set_wol(dev->phylink, wol);
+
exit_pm_put:
usb_autopm_put_interface(dev->intf);
--
2.55.0
Re: [PATCH net v2] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
Author: netdev-bot+sinfo
Date: Mon, 19 Oct 2026 19:39
Date: Mon, 19 Oct 2026 19:39
18 lines
8353 bytes
8353 bytes
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.
Re: [PATCH net v2] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
Author: Andrew Lunn
Date: Mon, 19 Oct 2026 21:24
Date: Mon, 19 Oct 2026 21:24
19 lines
8680 bytes
8680 bytes
> @@ -1805,7 +1805,9 @@ static int lan78xx_set_wol(struct net_device *netdev, > if (ret < 0) > goto exit_pm_put; > > - ret = phy_ethtool_set_wol(netdev->phydev, wol); > + if (phylink_expects_phy(dev->phylink)) Is phylink_expects_phy() actually needed? > + ret = phylink_ethtool_set_wol(dev->phylink, wol); We try to keep the phylink API simple, and put all the complexity within phylink. Hence it would be better if you could just call phylink_ethtool_set_wol() and at the MAC level not have to care about fixed link. phylink knows if there is a PHY, it should decide what to do. Andrew
Re: [PATCH net v2] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
Author: Prashant Sengar
Date: Tue, 20 Oct 2026 07:05
Date: Tue, 20 Oct 2026 07:05
48 lines
13350 bytes
13350 bytes
Hi Andrew, While testing the unconditional phylink_ethtool_set_wol() call, I noticed that it returns -EOPNOTSUPP for the PHY-less LAN7801 fixed-link configuration in my QEMU USB Raw Gadget setup. The NULL dereference is avoided, but lan78xx_set_wol() updates pdata->wol and the USB wakeup policy before calling phylink. I observed the following when disabling WoL: Before SET: WoL = 0x20, USB wakeup enabled SET WoL=0: -EOPNOTSUPP After SET: WoL = 0x00, USB wakeup disabled LAN78xx currently doesn't register a mac_wol_set callback with phylink, although it has its own controller-side WoL handling during suspend. I wanted to share this observation while investigating the WoL path. Is this behavior expected for the fixed-link configuration, or am I overlooking some existing handling? Thanks, Prashant On Tue, Oct 20, 2026 at 2:54 AM Andrew Lunn <andrew@lunn.ch> wrote: > > > @@ -1805,7 +1805,9 @@ static int lan78xx_set_wol(struct net_device *netdev, > > if (ret < 0) > > goto exit_pm_put; > > > > - ret = phy_ethtool_set_wol(netdev->phydev, wol); > > + if (phylink_expects_phy(dev->phylink)) > > Is phylink_expects_phy() actually needed? > > > + ret = phylink_ethtool_set_wol(dev->phylink, wol); > > We try to keep the phylink API simple, and put all the complexity > within phylink. Hence it would be better if you could just call > phylink_ethtool_set_wol() and at the MAC level not have to care about > fixed link. phylink knows if there is a PHY, it should decide what to > do. > > Andrew
Re: [PATCH net v2] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
Author: Andrew Lunn
Date: Tue, 20 Oct 2026 12:17
Date: Tue, 20 Oct 2026 12:17
43 lines
9805 bytes
9805 bytes
On Tue, Oct 20, 2026 at 12:35:04PM +0530, Prashant Sengar wrote: > Hi Andrew, > > While testing the unconditional phylink_ethtool_set_wol() call, I > noticed that it returns -EOPNOTSUPP for the PHY-less LAN7801 > fixed-link configuration in my QEMU USB Raw Gadget setup. > > The NULL dereference is avoided, but lan78xx_set_wol() updates > pdata->wol and the USB wakeup policy before calling phylink. I > observed the following when disabling WoL: > > Before SET: WoL = 0x20, USB wakeup enabled > SET WoL=0: -EOPNOTSUPP > After SET: WoL = 0x00, USB wakeup disabled > > LAN78xx currently doesn't register a mac_wol_set callback with > phylink, although it has its own controller-side WoL handling during > suspend. > > I wanted to share this observation while investigating the WoL path. > Is this behavior expected for the fixed-link configuration, or am I > overlooking some existing handling? WoL with fixed link is not the usual setup developers have, so it is probably untested. There might be issues here. So the first question is Why does it return EOPNOTSUPP? With phylink, it splits into two parts. The MAC driver needs to indicate it supports WoL by providing mac_wol_set() in its phylink_mac_ops, and indicating what WoL modes the MAC supports. Does the lan7801 have that? https://elixir.bootlin.com/linux/v7.3/source/drivers/net/usb/lan78xx.c#L2608 suggests it does not. Try implementing it. Look at what stmmac does. The second part is what does the PHY provide? phylink_phy_supports_wol() does check for a NULL phydev, so it looks O.K. Andrew
Re: [PATCH net v2] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
Author: Andrew Lunn
Date: Tue, 20 Oct 2026 14:02
Date: Tue, 20 Oct 2026 14:02
26 lines
9300 bytes
9300 bytes
On Tue, Oct 20, 2026 at 06:23:56PM +0530, Prashant Sengar wrote: > Thanks, Andrew. > > I understand that LAN78xx needs to advertise its MAC WoL capabilities and > implement mac_wol_set() for phylink to handle controller-managed WoL. > > Since this would involve additional changes and testing, I would like to keep > v3 focused on preventing the NULL dereference by calling > phylink_ethtool_set_wol() unconditionally. So there are two different things. 1) Avoid the crash. 2) Make it actually work with a fixed link. For net, you can do a quick and simple fix, which makes ethtool set wol/get_wol return EOPNOTSUPP if there is no PHY. It did not work before, it still does not work, so no regression. But the crash is gone. And keep calling phylib, rather than phylink. For net-next, you can add proper WoL support using phylink, and make fixed-link work. Since it never worked, this is new development, so should be for net-next. Andrew
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads