wifi: mac80211: reserve chanctx during find
authorJohannes Berg <johannes.berg@intel.com>
Thu, 18 Apr 2024 09:52:19 +0000 (11:52 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 19 Apr 2024 08:19:36 +0000 (10:19 +0200)
commit5e0c422d12b535cb3c7281d017f1a5b1b16098a5
treeed95df0c8fa7c89e138614c4c909c7c1f6f37dc5
parent62cc206cb18b6e4fbb78d027705cba95a555ec70
wifi: mac80211: reserve chanctx during find

When searching for a chanctx for re-use, it's later adjusted and
assigned. It may also be that another one is already assigned to
the link in question, so unassign can also happen. In short, the
driver is called multiple times. During these callbacks, it may
thus change active links (on another interface), which then can
in turn cause the found chanctx (that's going to be reused) to
get removed and freed.

To avoid this, temporarily assign it to the reserved chanctx and
track the link that wants to use it in the reserved_links list.
This causes the ieee80211_chanctx_refcount() to be increased by
one during these operations, thus avoiding the free.

Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://msgid.link/20240418115219.94ea84c8ee1e.I0b247dbc0cd937ae6367bc0fc7e8d156b5d5f9b1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/chan.c