DF-2341 / fix.diff
--- a/sys/bus/u4b/net/usb_ethernet.h +++ b/sys/bus/u4b/net/usb_ethernet.h @@ -102,6 +102,7 @@ struct usb_ether_cfg_task ue_tick_task[2]; int ue_unit; + int ue_if_attached; /* ether_ifattach() ran */ /* ethernet address from eeprom */ uint8_t ue_eaddr[ETHER_ADDR_LEN]; --- a/sys/bus/u4b/net/usb_ethernet.c +++ b/sys/bus/u4b/net/usb_ethernet.c @@ -241,6 +241,7 @@ if_printf(ifp, "<USB Ethernet> on %s\n", device_get_nameunit(ue->ue_dev)); ether_ifattach(ifp, ue->ue_eaddr, NULL); + ue->ue_if_attached = 1; /* Tell upper layer we support VLAN oversized frames. */ if (ifp->if_capabilities & IFCAP_VLAN_MTU) ifp->if_hdrlen = sizeof(struct ether_vlan_header); @@ -275,7 +276,9 @@ /* read "ifnet" pointer after taskqueue drain */ ifp = uether_getifp(ue); - if (ifp != NULL) { + /* the async attach task may have failed before ether_ifattach(); + * detaching a never-attached ifnet panics in if_detach() */ + if (ifp != NULL && ue->ue_if_attached) { /* we are not running any more */ UE_LOCK(ue); |