[PATCH 2/3] wifi: iwlwifi: mld: defer freeing PTK PN state on key failure

From: Zhao Li

Date: Mon Sep 14 2026 - 13:20:04 EST


The PTK packet-number state is published to RCU readers before the key is
installed in firmware.

If firmware rejects the key, the error path clears the pointer and
immediately frees the state while an RX reader may still hold it.

Defer the free until after an RCU grace period, matching the normal key
removal path.

Fixes: d1e879ec600f ("wifi: iwlwifi: add iwlmld sub-driver")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: Codex:gpt-6-astra
Signed-off-by: Zhao Li <enderaoelyther@xxxxxxxxx>
---
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mld/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mld/mac80211.c
index 3a4c8fda68d0..693f2092a781 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/mac80211.c
@@ -2265,7 +2265,7 @@ static int iwl_mld_set_key_add(struct iwl_mld *mld,
if (ret) {
if (ptk_pn) {
RCU_INIT_POINTER(mld_sta->ptk_pn[keyidx], NULL);
- kfree(ptk_pn);
+ kfree_rcu(ptk_pn, rcu_head);
}

return -EOPNOTSUPP;
--
2.55.0