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. Report no WoL capabilities when no PHY is attached, and return -EOPNOTSUPP from lan78xx_set_wol() before modifying the wakeup configuration. Keep the existing phylib WoL handling for devices with an attached PHY. 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 PHY-less configuration no longer advertises unsupported WoL operations, avoiding the crash. Fixes: e110bc825897 ("net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management") Signed-off-by: Prashant Sengar Reviewed-by: Andrew Lunn --- v4: - Remove the unrelated blank-line change noted in review. - Preserve the existing spacing in lan78xx_get_wol(). v3: - Report WoL as unsupported when no PHY is attached. - Keep the existing phylib WoL handling for attached PHYs. v2: - Use the phylink API instead of calling phylib directly. v1: https://lore.kernel.org/netdev/20261018151830.643511-1-prashantsengar25031@gmail.com/ drivers/net/usb/lan78xx.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 5655941f1478..4f100bec5b3a 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1764,6 +1764,12 @@ static void lan78xx_get_wol(struct net_device *netdev, u32 buf; struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0]); + if (!netdev->phydev) { + wol->supported = 0; + wol->wolopts = 0; + return; + } + if (usb_autopm_get_interface(dev->intf) < 0) return; @@ -1795,6 +1801,9 @@ static int lan78xx_set_wol(struct net_device *netdev, if (wol->wolopts & ~WAKE_ALL) return -EINVAL; + if (!netdev->phydev) + return -EOPNOTSUPP; + ret = usb_autopm_get_interface(dev->intf); if (ret < 0) return ret; -- 2.55.0