1 From 6ea51fc708aedcf411f355de65a704ecda501bc4 Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Thu, 6 Apr 2017 13:14:42 +0100
4 Subject: [PATCH] brcmfmac: only add channels and ssids once in scan request
6 When receiving pno results there may be duplicate channels and/or
7 ssids. Assure each is added only once when preparing the internal
10 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
11 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
12 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
13 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
16 .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 20 ++++++++++++++++----
17 1 file changed, 16 insertions(+), 4 deletions(-)
19 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
20 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
21 @@ -3216,7 +3216,7 @@ static int brcmf_internal_escan_add_info
23 struct ieee80211_channel *chan;
24 enum nl80211_band band;
28 if (channel <= CH_MAX_2G_CHANNEL)
29 band = NL80211_BAND_2GHZ;
30 @@ -3231,10 +3231,22 @@ static int brcmf_internal_escan_add_info
34 - req->channels[req->n_channels++] = chan;
35 - memcpy(req->ssids[req->n_ssids].ssid, ssid, ssid_len);
36 - req->ssids[req->n_ssids++].ssid_len = ssid_len;
38 + for (i = 0; i < req->n_channels; i++) {
39 + if (req->channels[i] == chan)
42 + if (i == req->n_channels)
43 + req->channels[req->n_channels++] = chan;
45 + for (i = 0; i < req->n_ssids; i++) {
46 + if (req->ssids[i].ssid_len == ssid_len &&
47 + !memcmp(req->ssids[i].ssid, ssid, ssid_len))
50 + if (i == req->n_ssids) {
51 + memcpy(req->ssids[req->n_ssids].ssid, ssid, ssid_len);
52 + req->ssids[req->n_ssids++].ssid_len = ssid_len;