]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: cfg80211: scan: skip duplicate RNR entries
authorJohannes Berg <johannes.berg@intel.com>
Wed, 1 Jan 2025 05:05:26 +0000 (07:05 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 13 Jan 2025 14:26:44 +0000 (15:26 +0100)
There really shouldn't be duplicate entries when we give
the list to the driver, and since we already have a list
it's easy to avoid.

While at it, remove the unnecessary allocation there.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250101070249.b0012c70f503.Id6fcad979434c1437340aa283abae2906345cca1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/scan.c

index 4f42cdaa363fedf1a9f42a0a65320dc8a648042b..a180f21b3d28dbc44784e893c6aaf5c7a3320e1e 100644 (file)
@@ -729,7 +729,7 @@ cfg80211_parse_colocated_ap_iter(void *_data, u8 type,
                                           bss_params)))
                return RNR_ITER_CONTINUE;
 
-       entry = kzalloc(sizeof(*entry) + IEEE80211_MAX_SSID_LEN, GFP_ATOMIC);
+       entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
        if (!entry)
                return RNR_ITER_ERROR;
 
@@ -738,6 +738,17 @@ cfg80211_parse_colocated_ap_iter(void *_data, u8 type,
 
        if (!cfg80211_parse_ap_info(entry, tbtt_info, tbtt_info_len,
                                    data->ssid_elem, data->s_ssid_tmp)) {
+               struct cfg80211_colocated_ap *tmp;
+
+               /* Don't add duplicate BSSIDs on the same channel. */
+               list_for_each_entry(tmp, &data->ap_list, list) {
+                       if (ether_addr_equal(tmp->bssid, entry->bssid) &&
+                           tmp->center_freq == entry->center_freq) {
+                               kfree(entry);
+                               return RNR_ITER_CONTINUE;
+                       }
+               }
+
                data->n_coloc++;
                list_add_tail(&entry->list, &data->ap_list);
        } else {