[PATCH 2/4] wifi: iwlwifi: mvm: clear P2P device pointer on add failure

From: Jiale Yao

Date: Wed Oct 28 2026 - 01:09:15 EST


The MLD add_interface path publishes p2p_device_vif before updating power
configuration. If that update fails, the remaining interface state is
unwound but the pointer still refers to the vif that mac80211 will free.

Clear the P2P device pointer before entering the common cleanup path.

Fixes: 84ef7cbe90e9 ("wifi: iwlwifi: mvm: Don't always bind/link the P2P Device interface")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
index 6ea9a7c8da0c..b1d4419a236c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
@@ -74,8 +74,11 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,
mvm->p2p_device_vif = vif;

ret = iwl_mvm_power_update_mac(mvm);
- if (ret)
+ if (ret) {
+ if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
+ mvm->p2p_device_vif = NULL;
goto out_free_bf;
+ }

iwl_mvm_tcm_add_vif(mvm, vif);

--
2.34.1