On Mon, Sep 14, 2026 at 08:10:26PM +0000, Mattéo Bianchi wrote: > Other drivers apparently avoid this by assigning a concrete > channel (typically ic->ic_ibss_chan, already computed by > ieee80211_setmode() during ieee80211_ifattach()) to > ic->ic_bss->ni_chan before or during their newstate handling. > urtw(4) never does this.
Then why not actually initialize it in urtw_init and urtw_8187b_init, and near the end of urtw_attach for good measure? Putting this in urtw_newstate seems overly specific to the particular crash path you've seen. There could be more paths to this crash. Maybe such paths don't exist right now, but some time in the future net80211 code could change and call some functions in a slightly different order. > Index: sys/dev/usb/if_urtw.c > =================================================================== > RCS file: /cvs/src/sys/dev/usb/if_urtw.c,v > retrieving revision 1.74 > diff -u -p -r1.74 if_urtw.c > --- sys/dev/usb/if_urtw.c > +++ sys/dev/usb/if_urtw.c > @@ -1018,6 +1018,16 @@ urtw_newstate(struct ieee80211com *ic, e > usb_rem_task(sc->sc_udev, &sc->sc_task); > timeout_del(&sc->scan_to); > > + /* > + * ic->ic_bss->ni_chan starts out as IEEE80211_CHAN_ANYC (NULL). > + * Give it a real channel before the generic 802.11 state machine, > + * invoked below via sc->sc_newstate() in urtw_task(), dereferences > + * ni_chan on the first INIT -> SCAN transition and panics. > + */ > + if (nstate == IEEE80211_S_SCAN && > + ic->ic_bss->ni_chan == IEEE80211_CHAN_ANYC) > + ic->ic_bss->ni_chan = ic->ic_ibss_chan; > + > /* do it in a process context */ > sc->sc_state = nstate; > sc->sc_arg = arg; > >
