Skip to content

Commit 72d5204

Browse files
Miriam-Racheljmberg-intel
authored andcommitted
wifi: cfg80211: cancel wiphy_work before freeing wiphy
A wiphy_work can be queued from the moment the wiphy is allocated and initialized (i.e. wiphy_new_nm). When a wiphy_work is queued, the rdev::wiphy_work is getting queued. If wiphy_free is called before the rdev::wiphy_work had a chance to run, the wiphy memory will be freed, and then when it eventally gets to run it'll use invalid memory. Fix this by canceling the work before freeing the wiphy. Fixes: a3ee4dc ("wifi: cfg80211: add a work abstraction with special semantics") Signed-off-by: Miri Korenblit <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Link: https://patch.msgid.link/20250306123626.efd1d19f6e07.I48229f96f4067ef73f5b87302335e2fd750136c9@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 9a267ce commit 72d5204

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/wireless/core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,13 @@ void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
11911191
{
11921192
struct cfg80211_internal_bss *scan, *tmp;
11931193
struct cfg80211_beacon_registration *reg, *treg;
1194+
unsigned long flags;
1195+
1196+
spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
1197+
WARN_ON(!list_empty(&rdev->wiphy_work_list));
1198+
spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
1199+
cancel_work_sync(&rdev->wiphy_work);
1200+
11941201
rfkill_destroy(rdev->wiphy.rfkill);
11951202
list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) {
11961203
list_del(&reg->list);

0 commit comments

Comments
 (0)