Skip to content

Commit c797dde

Browse files
jerome-pouillerjhedberg
authored andcommitted
drivers: wifi: siwx917: Fix mac address configuration
Zephyr only saves a pointer to the memory area provided to net_if_set_link_addr(). So the MAC address has to be stored in a static area (while it was stored in the stack). Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent ead505a commit c797dde

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/wifi/siwx917/siwx917_wifi.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ LOG_MODULE_REGISTER(siwx917_wifi);
2626

2727
struct siwx917_dev {
2828
struct net_if *iface;
29+
sl_mac_address_t macaddr;
2930
enum wifi_iface_state state;
3031
scan_result_cb_t scan_res_cb;
3132

@@ -621,7 +622,6 @@ static struct net_offload siwx917_offload = {
621622
static void siwx917_iface_init(struct net_if *iface)
622623
{
623624
struct siwx917_dev *sidev = iface->if_dev->dev->data;
624-
sl_mac_address_t mac_addr;
625625

626626
iface->if_dev->offload = &siwx917_offload;
627627
sidev->state = WIFI_STATE_INTERFACE_DISABLED;
@@ -630,8 +630,15 @@ static void siwx917_iface_init(struct net_if *iface)
630630

631631
sl_wifi_set_scan_callback(siwx917_on_scan, sidev);
632632
sl_wifi_set_join_callback(siwx917_on_join, sidev);
633-
sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, &mac_addr);
634-
net_if_set_link_addr(iface, mac_addr.octet, sizeof(mac_addr.octet), NET_LINK_ETHERNET);
633+
634+
status = sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, &sidev->macaddr);
635+
if (status) {
636+
LOG_ERR("sl_wifi_get_mac_address(): %#04x", status);
637+
return;
638+
}
639+
net_if_set_link_addr(iface, sidev->macaddr.octet, sizeof(sidev->macaddr.octet),
640+
NET_LINK_ETHERNET);
641+
635642
sidev->state = WIFI_STATE_INACTIVE;
636643
}
637644

0 commit comments

Comments
 (0)