From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH wireless-next 22/28] wifi: mac80211: Add force-cleanup call to driver.
Date: Wed, 11 Mar 2026 16:07:24 -0700 [thread overview]
Message-ID: <20260311230730.163348-23-greearb@candelatech.com> (raw)
In-Reply-To: <20260311230730.163348-1-greearb@candelatech.com>
From: Ben Greear <greearb@candelatech.com>
When hardware is determined by mac80211 to be in non-recoverable
state, then SDATA_IN_DRIVER flag is removed, and mac80211 will no
longer do any 'graceful' teardown of the objects in the driver.
This was causing use-after-free crashes in the iwlwifi driver
since it's logic to do internal cleanup is not quite right for
some reason.
Add an explicit callback to the driver to tell it to clean up
whatever it needs to clean up in case mac80211 considers it
dead.
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
include/net/mac80211.h | 7 +++++++
net/mac80211/driver-ops.h | 8 ++++++++
net/mac80211/util.c | 5 +++++
3 files changed, 20 insertions(+)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 9cc482191ab9..d963f213863b 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3934,6 +3934,12 @@ struct ieee80211_prep_tx_info {
* you should ensure to cancel it on this callback.
* Must be implemented and can sleep.
*
+ * @force_cleanup: Called after mac80211 determines the
+ * driver/firmware/hardware has failed and cannot
+ * be restarted. SDATA_IN_DRIVER is false at this point,
+ * so normal cleanup will not happen. This force_cleanup
+ * operation lets the driver do any needed houskeeping.
+ *
* @suspend: Suspend the device; mac80211 itself will quiesce before and
* stop transmitting and doing any other configuration, and then
* ask the device to suspend. This is only invoked when WoWLAN is
@@ -4569,6 +4575,7 @@ struct ieee80211_ops {
struct sk_buff *skb);
int (*start)(struct ieee80211_hw *hw);
void (*stop)(struct ieee80211_hw *hw, bool suspend);
+ void (*force_cleanup)(struct ieee80211_hw *hw);
#ifdef CONFIG_PM
int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
int (*resume)(struct ieee80211_hw *hw);
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index e2283d7dcd1e..3bd3d078ce9b 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -300,6 +300,14 @@ static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
trace_drv_return_void(local);
}
+static inline void
+drv_force_cleanup(struct ieee80211_local *local)
+{
+ lockdep_assert_wiphy(local->hw.wiphy);
+ if (local->ops->force_cleanup)
+ local->ops->force_cleanup(&local->hw);
+}
+
static inline int
drv_sched_scan_start(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 55054de62508..ec11ee6b8752 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1692,6 +1692,11 @@ static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local)
*/
list_for_each_entry(ctx, &local->chanctx_list, list)
ctx->driver_present = false;
+
+ /* Tell driver to purge any remaining configuration it may have
+ * lingering around.
+ */
+ drv_force_cleanup(local);
}
static void ieee80211_assign_chanctx(struct ieee80211_local *local,
--
2.42.0
next prev parent reply other threads:[~2026-03-11 23:07 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 23:07 [PATCH wireless-next 00/28] iwlwifi + mac80211 stability greearb
2026-03-11 23:07 ` [PATCH wireless-next 01/28] wifi: iwlwifi: mld: Check for NULL before lookup greearb
2026-03-11 23:07 ` [PATCH wireless-next 02/28] wifi: iwlwifi: mld: Fix un-set return value in error case greearb
2026-03-11 23:07 ` [PATCH wireless-next 03/28] wifi: iwlwifi: mld: Add check for null vif in stats callback greearb
2026-03-11 23:07 ` [PATCH wireless-next 04/28] wifi: mac80211: Check debugfs creation return values greearb
2026-03-11 23:07 ` [PATCH wireless-next 05/28] wifi: mac80211: do not fail taking sta to lower state greearb
2026-03-11 23:07 ` [PATCH wireless-next 06/28] wifi: mac80211: Mark sta as uploaded if single transition succeeds greearb
2026-03-11 23:07 ` [PATCH wireless-next 07/28] wifi: mac80211: Fix use-after-free of debugfs inodes greearb
2026-03-11 23:07 ` [PATCH wireless-next 08/28] wifi: mac80211: Debugfs safety checks greearb
2026-03-11 23:07 ` [PATCH wireless-next 09/28] wifi: mac80211: Use warn-on-once in drv_remove_chanctxt greearb
2026-03-11 23:07 ` [PATCH wireless-next 10/28] wifi: mac80211: Ensure sta debugfs is not double-freed greearb
2026-03-11 23:07 ` [PATCH wireless-next 11/28] wifi: iwlwifi: mld: Fix stale reference in fw_id_to_link_sta greearb
2026-03-11 23:07 ` [PATCH wireless-next 12/28] wifi: iwlwifi: mld: Improve logging in error cases greearb
2026-03-11 23:07 ` [PATCH wireless-next 13/28] wifi: iwlwifi: mld: Remove warning about BAID greearb
2026-03-11 23:07 ` [PATCH wireless-next 14/28] wifi: mac80211: Add dmesg log regarding warn-on in drv-stop greearb
2026-03-11 23:07 ` [PATCH wireless-next 15/28] wifi: iwlwifi: mld: Fix use-after-free of bss_conf greearb
2026-03-11 23:07 ` [PATCH wireless-next 16/28] wifi: iwlwifi: mld: Check for null in iwl_mld_wait_sta_txqs_empty greearb
2026-03-11 23:07 ` [PATCH wireless-next 17/28] wifi: iwlwifi: mld: use warn-on-once in error path greearb
2026-03-11 23:07 ` [PATCH wireless-next 18/28] wifi: iwlwifi: mld: Use warn-on-once in emlsr exit logic greearb
2026-03-11 23:07 ` [PATCH wireless-next 19/28] wifi: iwlwifi: mld: Improve error message in rx path greearb
2026-03-11 23:07 ` [PATCH wireless-next 20/28] wifi: iwlwifi: mld: Improve logging message greearb
2026-03-11 23:07 ` [PATCH wireless-next 21/28] wifi: iwlwifi: mld: Protect from null mld_sta greearb
2026-03-11 23:07 ` greearb [this message]
2026-03-11 23:07 ` [PATCH wireless-next 23/28] wifi: iwlwifi: mld: Support force-cleanup op greearb
2026-03-11 23:07 ` [PATCH wireless-next 24/28] wifi: iwlwifi: mld: Fix NPE in flush logic greearb
2026-03-11 23:07 ` [PATCH wireless-next 25/28] wifi: iwlwifi: mld: Fix bad return address in tx code greearb
2026-03-11 23:07 ` [PATCH wireless-next 26/28] wifi: mac80211: Ensure link work-items are only initialized once greearb
2026-03-11 23:07 ` [PATCH wireless-next 27/28] wifi: iwlwifi: mld: Convert to WARN_ONCE in link removal path greearb
2026-03-11 23:07 ` [PATCH wireless-next 28/28] wifi: mac80211: Decrease WARN spam greearb
2026-03-12 14:25 ` [syzbot ci] Re: iwlwifi + mac80211 stability syzbot ci
2026-03-12 15:25 ` Ben Greear
2026-03-12 17:44 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260311230730.163348-23-greearb@candelatech.com \
--to=greearb@candelatech.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox