]> Git Repo - linux.git/commitdiff
wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys
authorFelix Fietkau <[email protected]>
Sun, 6 Oct 2024 15:36:30 +0000 (17:36 +0200)
committerJohannes Berg <[email protected]>
Tue, 8 Oct 2024 19:24:20 +0000 (21:24 +0200)
Sync iterator conditions with ieee80211_iter_keys_rcu.

Fixes: 830af02f24fb ("mac80211: allow driver to iterate keys")
Signed-off-by: Felix Fietkau <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
net/mac80211/key.c

index eecdd2265eaa6351ff6653f6af7b3ce7dc72b0f7..e45b5f56c4055a466a8d86e41a84278b7ee20238 100644 (file)
@@ -987,6 +987,26 @@ void ieee80211_reenable_keys(struct ieee80211_sub_if_data *sdata)
        }
 }
 
        }
 }
 
+static void
+ieee80211_key_iter(struct ieee80211_hw *hw,
+                  struct ieee80211_vif *vif,
+                  struct ieee80211_key *key,
+                  void (*iter)(struct ieee80211_hw *hw,
+                               struct ieee80211_vif *vif,
+                               struct ieee80211_sta *sta,
+                               struct ieee80211_key_conf *key,
+                               void *data),
+                  void *iter_data)
+{
+       /* skip keys of station in removal process */
+       if (key->sta && key->sta->removed)
+               return;
+       if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
+               return;
+       iter(hw, vif, key->sta ? &key->sta->sta : NULL,
+            &key->conf, iter_data);
+}
+
 void ieee80211_iter_keys(struct ieee80211_hw *hw,
                         struct ieee80211_vif *vif,
                         void (*iter)(struct ieee80211_hw *hw,
 void ieee80211_iter_keys(struct ieee80211_hw *hw,
                         struct ieee80211_vif *vif,
                         void (*iter)(struct ieee80211_hw *hw,
@@ -1005,16 +1025,13 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
        if (vif) {
                sdata = vif_to_sdata(vif);
                list_for_each_entry_safe(key, tmp, &sdata->key_list, list)
        if (vif) {
                sdata = vif_to_sdata(vif);
                list_for_each_entry_safe(key, tmp, &sdata->key_list, list)
-                       iter(hw, &sdata->vif,
-                            key->sta ? &key->sta->sta : NULL,
-                            &key->conf, iter_data);
+                       ieee80211_key_iter(hw, vif, key, iter, iter_data);
        } else {
                list_for_each_entry(sdata, &local->interfaces, list)
                        list_for_each_entry_safe(key, tmp,
                                                 &sdata->key_list, list)
        } else {
                list_for_each_entry(sdata, &local->interfaces, list)
                        list_for_each_entry_safe(key, tmp,
                                                 &sdata->key_list, list)
-                               iter(hw, &sdata->vif,
-                                    key->sta ? &key->sta->sta : NULL,
-                                    &key->conf, iter_data);
+                               ieee80211_key_iter(hw, &sdata->vif, key,
+                                                  iter, iter_data);
        }
 }
 EXPORT_SYMBOL(ieee80211_iter_keys);
        }
 }
 EXPORT_SYMBOL(ieee80211_iter_keys);
@@ -1031,17 +1048,8 @@ _ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
 {
        struct ieee80211_key *key;
 
 {
        struct ieee80211_key *key;
 
-       list_for_each_entry_rcu(key, &sdata->key_list, list) {
-               /* skip keys of station in removal process */
-               if (key->sta && key->sta->removed)
-                       continue;
-               if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
-                       continue;
-
-               iter(hw, &sdata->vif,
-                    key->sta ? &key->sta->sta : NULL,
-                    &key->conf, iter_data);
-       }
+       list_for_each_entry_rcu(key, &sdata->key_list, list)
+               ieee80211_key_iter(hw, &sdata->vif, key, iter, iter_data);
 }
 
 void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
 }
 
 void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
This page took 0.062741 seconds and 4 git commands to generate.