Message ID | 20220328095745.19516-1-qianfanguijin@163.com |
---|---|
State | Superseded |
Delegated to: | Ramon Fried |
Headers | show |
Series | [v2,1/2] net: eth-uclass: Fix eth_halt | expand |
diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 58c308f332..c6eb1bc8f8 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -338,9 +338,14 @@ void eth_halt(void) if (!priv || !priv->running) return; - eth_get_ops(current)->stop(current); - priv->state = ETH_STATE_PASSIVE; + /* Make sure setting private data before @stop handler, it may remove + * ethernet device and will cause @priv unaccessable. + * eg: + * usb_eth_stop -> usb_gadget_release -> device_remove + */ priv->running = false; + + eth_get_ops(current)->stop(current); } int eth_is_active(struct udevice *dev)