]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: iwlwifi: fix aux ROC time event iterator usage
authorJunjie Cao <junjie.cao@intel.com>
Thu, 16 Oct 2025 01:49:19 +0000 (09:49 +0800)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 12 Nov 2025 07:54:46 +0000 (09:54 +0200)
The list_for_each_entry() iterator must not be used outside the loop.
Even though we break and check for NULL, doing so still violates kernel
iteration rules and triggers Coccinelle's use_after_iter.cocci warning.

Cache the matched entry in aux_roc_te and use it consistently after the
loop. This follows iterator best practices, resolves the warning, and
makes the code more maintainable.

Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Link: https://patch.msgid.link/20251016014919.383565-1-junjie.cao@intel.com
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c

index 0c9c2492d8a75907bf9e3b00ac4bccabb1fb80c0..0b12ee8ad6180bbab70e23a102d32615e44b1847 100644 (file)
@@ -463,7 +463,7 @@ static int iwl_mvm_aux_roc_te_handle_notif(struct iwl_mvm *mvm,
        if (!aux_roc_te) /* Not a Aux ROC time event */
                return -EINVAL;
 
-       iwl_mvm_te_check_trigger(mvm, notif, te_data);
+       iwl_mvm_te_check_trigger(mvm, notif, aux_roc_te);
 
        IWL_DEBUG_TE(mvm,
                     "Aux ROC time event notification  - UID = 0x%x action %d (error = %d)\n",
@@ -475,14 +475,14 @@ static int iwl_mvm_aux_roc_te_handle_notif(struct iwl_mvm *mvm,
                /* End TE, notify mac80211 */
                ieee80211_remain_on_channel_expired(mvm->hw);
                iwl_mvm_roc_finished(mvm); /* flush aux queue */
-               list_del(&te_data->list); /* remove from list */
-               te_data->running = false;
-               te_data->vif = NULL;
-               te_data->uid = 0;
-               te_data->id = TE_MAX;
+               list_del(&aux_roc_te->list); /* remove from list */
+               aux_roc_te->running = false;
+               aux_roc_te->vif = NULL;
+               aux_roc_te->uid = 0;
+               aux_roc_te->id = TE_MAX;
        } else if (le32_to_cpu(notif->action) == TE_V2_NOTIF_HOST_EVENT_START) {
                set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status);
-               te_data->running = true;
+               aux_roc_te->running = true;
                ieee80211_ready_on_channel(mvm->hw); /* Start TE */
        } else {
                IWL_DEBUG_TE(mvm,