From: Johannes Berg <johannes.berg@xxxxxxxxx> 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@xxxxxxxxx> Reviewed-by: Ilan Peer <ilan.peer@xxxxxxxxx> Reviewed-by: Benjamin Berg <benjamin.berg@xxxxxxxxx> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@xxxxxxxxx> --- net/wireless/scan.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index d056248c43d2..ec9c071915f3 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -704,7 +704,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; @@ -713,6 +713,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 { -- 2.34.1