Skip to content

Commit e124c1c

Browse files
committed
eth: mcux: Do not set carrier ON if interface is not known
It is possible that the network interface is not yet initialized when status of the PHY changes. In this case we must not call net_eth_carrier_on() as that will cause a crash. This was noticed with mimxrt1050_evk board. Fixes: #21257 Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 7417e6e commit e124c1c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/ethernet/eth_mcux.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,12 @@ static void eth_mcux_phy_event(struct eth_context *context)
334334
kENET_MiiReadValidFrame);
335335
context->link_up = link_up;
336336
context->phy_state = eth_mcux_phy_state_read_duplex;
337-
net_eth_carrier_on(context->iface);
338-
k_sleep(USEC_PER_MSEC);
337+
338+
/* Network interface might be NULL at this point */
339+
if (context->iface) {
340+
net_eth_carrier_on(context->iface);
341+
k_sleep(USEC_PER_MSEC);
342+
}
339343
} else if (!link_up && context->link_up) {
340344
LOG_INF("Link down");
341345
context->link_up = link_up;

0 commit comments

Comments
 (0)