Skip to content

Commit 8e55d0b

Browse files
author
Arto Kinnunen
authored
Check interface before reading MAC address (#209)
Add checks around MAC address read to avoid HardFault in case of EthernetInterface creation fails.
1 parent e45f8c7 commit 8e55d0b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/border_router_main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ void backhaul_driver_init(void (*backhaul_driver_status_cb)(uint8_t, int8_t))
140140
/* Let the core code choose address - either from board or EMAC (for
141141
* ETH and SLIP we pass in the board address already in mac[]) */
142142
nsapi_error_t err = Nanostack::get_instance().add_ethernet_interface(emac, true, &ns_if);
143-
/* Read back what they chose into our mac[] */
144-
ns_if->get_mac_address(mac);
143+
if (err == NSAPI_ERROR_OK) {
144+
/* Read back what they chose into our mac[] */
145+
ns_if->get_mac_address(mac);
146+
}
145147
#else
146148
nsapi_error_t err = Nanostack::get_instance().add_ethernet_interface(emac, true, &ns_if, mac);
147149
#endif

0 commit comments

Comments
 (0)