]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: mld: introduce iwl_mld_vif_fw_id_valid
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Sat, 21 Mar 2026 17:29:19 +0000 (19:29 +0200)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 25 Mar 2026 09:31:58 +0000 (11:31 +0200)
Introduce a helper function that checks if a vif fw id is valid, and warns
if it isn't.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260321192637.b68d43db2ddc.I11b2b98e115da9eec8f603c5a01a0a9bcd040884@changeid
drivers/net/wireless/intel/iwlwifi/mld/iface.h
drivers/net/wireless/intel/iwlwifi/mld/low_latency.c

index 0857ae28be8e23776ab8d4a0a78cbf06e07d19fb..8dfc79fed253443536766d354c8d6ac43adeb681 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2024-2025 Intel Corporation
+ * Copyright (C) 2024-2026 Intel Corporation
  */
 #ifndef __iwl_mld_iface_h__
 #define __iwl_mld_iface_h__
@@ -203,6 +203,15 @@ iwl_mld_vif_to_mac80211(struct iwl_mld_vif *mld_vif)
        return container_of((void *)mld_vif, struct ieee80211_vif, drv_priv);
 }
 
+/* Call only for interfaces that were added to the driver! */
+static inline bool iwl_mld_vif_fw_id_valid(struct iwl_mld_vif *mld_vif)
+{
+       if (WARN_ON(mld_vif->fw_id >= ARRAY_SIZE(mld_vif->mld->fw_id_to_vif)))
+               return false;
+
+       return true;
+}
+
 #define iwl_mld_link_dereference_check(mld_vif, link_id)               \
        rcu_dereference_check((mld_vif)->link[link_id],                 \
                              lockdep_is_held(&mld_vif->mld->wiphy->mtx))
index d39dd36b08e3927632e561e90b4068c1097c81c1..a4ddc32e28609bc4eba0ed59e4d1261fcdfb5b28 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2024-2025 Intel Corporation
+ * Copyright (C) 2024-2026 Intel Corporation
  */
 #include "mld.h"
 #include "iface.h"
@@ -77,9 +77,12 @@ static void iwl_mld_low_latency_iter(void *_data, u8 *mac,
        bool prev = mld_vif->low_latency_causes & LOW_LATENCY_TRAFFIC;
        bool low_latency;
 
-       if (WARN_ON(mld_vif->fw_id >= ARRAY_SIZE(mld->low_latency.result)))
+       if (!iwl_mld_vif_fw_id_valid(mld_vif))
                return;
 
+       BUILD_BUG_ON(ARRAY_SIZE(mld->fw_id_to_vif) !=
+                    ARRAY_SIZE(mld->low_latency.result));
+
        low_latency = mld->low_latency.result[mld_vif->fw_id];
 
        if (prev != low_latency)
@@ -272,8 +275,10 @@ void iwl_mld_low_latency_update_counters(struct iwl_mld *mld,
        if (WARN_ON_ONCE(!mld->low_latency.pkts_counters))
                return;
 
-       if (WARN_ON_ONCE(fw_id >= ARRAY_SIZE(counters->vo_vi) ||
-                        queue >= mld->trans->info.num_rxqs))
+       if (!iwl_mld_vif_fw_id_valid(mld_vif))
+               return;
+
+       if (WARN_ON_ONCE(queue >= mld->trans->info.num_rxqs))
                return;
 
        if (mld->low_latency.stopped)