* [PATCH net v4] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
@ 2026-10-20 20:15 Prashant Sengar
0 siblings, 0 replies; only message in thread
From: Prashant Sengar @ 2026-10-20 20:15 UTC (permalink / raw)
To: netdev; +Cc: Thangaraj.S, UNGLinuxDriver, andrew+netdev, linux-usb
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 <prashantsengar25031@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-20 20:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 20:15 [PATCH net v4] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup Prashant Sengar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox