Skip to content

Commit

Permalink
eth: mcux: Do not set carrier ON if interface is not known
Browse files Browse the repository at this point in the history
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: zephyrproject-rtos#21257

(cherry picked from commit e124c1c)

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar authored and armandciejak committed Feb 19, 2020
1 parent 9e51635 commit 44c421c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/ethernet/eth_mcux.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,12 @@ static void eth_mcux_phy_event(struct eth_context *context)
kENET_MiiReadValidFrame);
context->link_up = link_up;
context->phy_state = eth_mcux_phy_state_read_duplex;
net_eth_carrier_on(context->iface);
k_sleep(USEC_PER_MSEC);

/* Network interface might be NULL at this point */
if (context->iface) {
net_eth_carrier_on(context->iface);
k_sleep(USEC_PER_MSEC);
}
} else if (!link_up && context->link_up) {
LOG_INF("Link down");
context->link_up = link_up;
Expand Down

0 comments on commit 44c421c

Please sign in to comment.