Commit e863ff80 authored by Oleksij Rempel's avatar Oleksij Rempel Committed by Jakub Kicinski
Browse files

net: usb: lan78xx: Fix refcounting and autosuspend on invalid WoL configuration



Validate Wake-on-LAN (WoL) options in `lan78xx_set_wol` before calling
`usb_autopm_get_interface`. This prevents USB autopm refcounting issues
and ensures the adapter can properly enter autosuspend when invalid WoL
options are provided.

Fixes: eb9ad088 ("lan78xx: Check for supported Wake-on-LAN modes")
Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Link: https://patch.msgid.link/20241118140351.2398166-1-o.rempel@pengutronix.de


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 614f4d16
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1652,13 +1652,13 @@ static int lan78xx_set_wol(struct net_device *netdev,
	struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0]);
	int ret;

	if (wol->wolopts & ~WAKE_ALL)
		return -EINVAL;

	ret = usb_autopm_get_interface(dev->intf);
	if (ret < 0)
		return ret;

	if (wol->wolopts & ~WAKE_ALL)
		return -EINVAL;

	pdata->wol = wol->wolopts;

	device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);