Re: [PATCH] wifi: mac80211_hwsim: remove radios from rhashtable before freeing

From: Johannes Berg

Date: Mon Jul 06 2026 - 09:53:34 EST


On Mon, 2026-07-06 at 20:10 +0800, Cen Zhang wrote:
> Hi Johannes,
>
> > How does the init even fail? I think this is fairly contrived,
> > especially in a test tool. The whole thing is maybe worth a cleanup, but
> > the whole scary commit message is nonsense.
> >
> > johannes
>
> Thanks for your review.
>
> The init failure I had in mind is a late one after radios have already
> been created and inserted into hwsim_radios_rht, for example in the
> monitor netdev setup after the radio loop. My local validation used
> fault injection at dev_alloc_name() plus a bounded debug delay to make
> that unwind window observable.

Yeah, I guess it _could_ technically happen, though I think the memory
allocation failures should be virtually impossible here. And it's hwsim
after all.

> That means the test shows the cleanup ordering issue, but it is indeed
> contrived, especially for mac80211_hwsim. The changelog I sent made this
> sound much scarier than it should have, and including the long KASAN
> report was not helpful.

Fair.

> The actual change I wanted is just the small consistency cleanup:
> mac80211_hwsim_free() should remove data->rht before freeing the radio,
> like the other radio removal paths already do.

I'd apply this, or maybe a reverse of ordering (making things visible
only after the radios exist), but please resend.

Also, if it's going to be this version, we don't really need
hwsim_radios_generation I think, anyway it's all going away so
consistency to userspace is effectively already dead at that point.

johannes