]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: usb: lan78xx: Fix refcounting and autosuspend on invalid WoL configuration
authorOleksij Rempel <o.rempel@pengutronix.de>
Mon, 18 Nov 2024 14:03:51 +0000 (15:03 +0100)
committerJakub Kicinski <kuba@kernel.org>
Mon, 25 Nov 2024 00:50:55 +0000 (16:50 -0800)
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: eb9ad088f966 ("lan78xx: Check for supported Wake-on-LAN modes")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://patch.msgid.link/20241118140351.2398166-1-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/usb/lan78xx.c

index 9f191b6ce8215244325d9087be7b98dc355a4b12..531b1b6a37d1900c53dc22ca01d13212e5510c21 100644 (file)
@@ -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);