Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
@ 2026-10-18 15:18 Prashant Sengar
  2026-10-18 16:21 ` Andrew Lunn
  2026-10-19 15:20 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Prashant Sengar @ 2026-10-18 15:18 UTC (permalink / raw)
  To: netdev; +Cc: Thangaraj.S, UNGLinuxDriver, linux-usb

LAN7801 supports fixed-link configurations without an attached PHY.
However, lan78xx_set_wol() unconditionally passes netdev->phydev
to phy_ethtool_set_wol(), which dereferences the missing PHY.

Only call the PHY Wake-on-LAN helper when a PHY is attached.

The issue was reproduced with USB Raw Gadget and dummy_hcd in QEMU.
The unmodified driver triggered a NULL pointer dereference.
With this change, the same ioctl completes successfully.

Fixes: e110bc825897 ("net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management")

Signed-off-by: Prashant Sengar <prashantsengar25031@gmail.com>
---
 drivers/net/usb/lan78xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 5655941f1478..0c19a8462352 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1804,8 +1804,8 @@ static int lan78xx_set_wol(struct net_device *netdev,
 	ret = device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);
 	if (ret < 0)
 		goto exit_pm_put;
-
-	ret = phy_ethtool_set_wol(netdev->phydev, wol);
+	if (netdev->phydev)
+		ret = phy_ethtool_set_wol(netdev->phydev, wol);
 
 exit_pm_put:
 	usb_autopm_put_interface(dev->intf);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-19 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-18 15:18 [PATCH net] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup Prashant Sengar
2026-10-18 16:21 ` Andrew Lunn
2026-10-19 15:20 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox