net: dsa: microchip: Fix Wake-on-LAN check to not return an error
PATCH 1/1 net: dsa: microchip: Fix Wake-on-LAN check to not return an error
From: Tristram Ha <[email protected]>
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.
--- drivers/net/dsa/microchip/ksz_common.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/dsa/microchip/ksz_common.c +6 -0
@@ -3764,6 +3764,12 @@ 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.supported =0 ; + wol.wolopts =0 ; +ksz_get_wol (ds, dp->index, &wol);if (wol.wolopts &WAKE_MAGIC ) { dev_err(ds->dev,
Signature · 1 line
2.34.1
Quoted 20 lines · On Thu, Aug 01, 2024 at 05:05:10PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
The wol variable in
ksz_port_set_mac_address()is declared with random data, but the code inksz_get_wolcall may not be executed so theWAKE_MAGICcheck 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 <[email protected]>--- drivers/net/dsa/microchip/ksz_common.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/dsa/microchip/ksz_common.c +0
-0@@ -3764,6 +3764,12 @@ static int ksz_port_set_mac_address(struct dsa_switch *ds, int port,return -EBUSY ; }
drivers/net/dsa/microchip/ksz_common.c static int ksz_port_set_mac_address(struct dsa_switch *ds, int port, · line 3775
Quoted 10 lines
drivers/net/dsa/microchip/ksz_common.c +6
-0+/* Need to initialize variable as the code to fill in settings may +* not be executed. +*/ + wol.supported =0 ; + wol.wolopts =0 ; +ksz_get_wol (ds, dp->index, &wol);if (wol.wolopts &WAKE_MAGIC ) { dev_err(ds->dev,
Only wol.wolopts need to be cleared. wol.supported can be dropped.
With this change:
Regards,
Oleksij
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |