net: dsa: microchip: Fix Wake-on-LAN check to not return an error
authorTristram Ha <tristram.ha@microchip.com>
Mon, 5 Aug 2024 23:52:00 +0000 (16:52 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 7 Aug 2024 02:32:54 +0000 (19:32 -0700)
The wol variable in ksz_port_set_mac_address() is declared with random
data, but the code in ksz_get_wol call may not be executed so the
WAKE_MAGIC check may be invalid resulting in an error message when
setting a MAC address after starting the DSA driver.

Fixes: 3b454b6390c3 ("net: dsa: microchip: ksz9477: Add Wake on Magic Packet support")
Signed-off-by: Tristram Ha <tristram.ha@microchip.com>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20240805235200.24982-1-Tristram.Ha@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/microchip/ksz_common.c

index b074b4bb062964850042634732438682f43e192d..b120e66d56694402258a1d73dcd6a0d388671f7b 100644 (file)
@@ -3764,6 +3764,11 @@ static int ksz_port_set_mac_address(struct dsa_switch *ds, int port,
                return -EBUSY;
        }
 
+       /* Need to initialize variable as the code to fill in settings may
+        * not be executed.
+        */
+       wol.wolopts = 0;
+
        ksz_get_wol(ds, dp->index, &wol);
        if (wol.wolopts & WAKE_MAGIC) {
                dev_err(ds->dev,