diff mbox series

[v2,4/5] brcmfmac: Update SSID of hidden AP while informing its bss to cfg80211 layer

Message ID 20220922104229.12119-5-ian.lin@infineon.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series Fix connect/p2p issue series | expand

Commit Message

Ian Lin Sept. 22, 2022, 10:42 a.m. UTC
From: Syed Rafiuddeen <syed.rafiuddeen@cypress.com>

cfg80211 layer on DUT STA is disconnecting ongoing connection attempt after
receiving association response, because cfg80211 layer does not have valid
AP bss information. On association response event, brcmfmac communicates
the AP bss information to cfg80211 layer, but SSID seem to be empty in AP
bss information, and cfg80211 layer prints kernel warning and then
disconnects the ongoing connection attempt.

SSID is empty in SSID IE, but 'bi->SSID' contains a valid SSID, so
updating the SSID for hidden AP while informing its bss information
to cfg80211 layer.

Signed-off-by: Syed Rafiuddeen <syed.rafiuddeen@cypress.com>
Signed-off-by: Chung-Hsien Hsu <chung-hsien.hsu@infineon.com>
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@infineon.com>
Signed-off-by: Ian Lin <ian.lin@infineon.com>
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c    | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

kernel test robot Sept. 22, 2022, 1:12 p.m. UTC | #1
Hi Ian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.0-rc6 next-20220921]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ian-Lin/Fix-connect-p2p-issue-series/20220922-184424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
config: m68k-allyesconfig
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/620f981fff55c74cd1fa86e5b6c177d51344f654
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ian-Lin/Fix-connect-p2p-issue-series/20220922-184424
        git checkout 620f981fff55c74cd1fa86e5b6c177d51344f654
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/net/wireless/broadcom/brcm80211/brcmfmac/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/string.h:20,
                    from include/linux/bitmap.h:11,
                    from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/spinlock.h:62,
                    from include/linux/wait.h:9,
                    from include/linux/wait_bit.h:8,
                    from include/linux/fs.h:6,
                    from include/linux/highmem.h:5,
                    from include/linux/bvec.h:10,
                    from include/linux/skbuff.h:17,
                    from include/linux/if_ether.h:19,
                    from include/linux/etherdevice.h:20,
                    from drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:9:
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function 'brcmf_inform_single_bss':
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3039:28: warning: passing argument 1 of '__builtin_memcpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    3039 |                 memcpy(ssid->data, bi->SSID, bi->SSID_len);
         |                        ~~~~^~~~~~
   arch/m68k/include/asm/string.h:72:42: note: in definition of macro 'memcpy'
      72 | #define memcpy(d, s, n) __builtin_memcpy(d, s, n)
         |                                          ^
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3039:28: note: expected 'void *' but argument is of type 'const u8 *' {aka 'const unsigned char *'}
    3039 |                 memcpy(ssid->data, bi->SSID, bi->SSID_len);
         |                        ~~~~^~~~~~
   arch/m68k/include/asm/string.h:72:42: note: in definition of macro 'memcpy'
      72 | #define memcpy(d, s, n) __builtin_memcpy(d, s, n)
         |                                          ^


vim +3039 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

  2990	
  2991	static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
  2992					   struct brcmf_bss_info_le *bi)
  2993	{
  2994		struct wiphy *wiphy = cfg_to_wiphy(cfg);
  2995		struct brcmf_pub *drvr = cfg->pub;
  2996		struct cfg80211_bss *bss;
  2997		enum nl80211_band band;
  2998		struct brcmu_chan ch;
  2999		u16 channel;
  3000		u32 freq;
  3001		u16 notify_capability;
  3002		u16 notify_interval;
  3003		u8 *notify_ie;
  3004		size_t notify_ielen;
  3005		struct cfg80211_inform_bss bss_data = {};
  3006		const struct brcmf_tlv *ssid = NULL;
  3007	
  3008		if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
  3009			bphy_err(drvr, "Bss info is larger than buffer. Discarding\n");
  3010			return -EINVAL;
  3011		}
  3012	
  3013		if (!bi->ctl_ch) {
  3014			ch.chspec = le16_to_cpu(bi->chanspec);
  3015			cfg->d11inf.decchspec(&ch);
  3016			bi->ctl_ch = ch.control_ch_num;
  3017		}
  3018		channel = bi->ctl_ch;
  3019	
  3020		if (channel <= CH_MAX_2G_CHANNEL)
  3021			band = NL80211_BAND_2GHZ;
  3022		else
  3023			band = NL80211_BAND_5GHZ;
  3024	
  3025		freq = ieee80211_channel_to_frequency(channel, band);
  3026		bss_data.chan = ieee80211_get_channel(wiphy, freq);
  3027		bss_data.scan_width = NL80211_BSS_CHAN_WIDTH_20;
  3028		bss_data.boottime_ns = ktime_to_ns(ktime_get_boottime());
  3029	
  3030		notify_capability = le16_to_cpu(bi->capability);
  3031		notify_interval = le16_to_cpu(bi->beacon_period);
  3032		notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
  3033		notify_ielen = le32_to_cpu(bi->ie_length);
  3034		bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
  3035	
  3036		ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
  3037		if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
  3038			/* Update SSID for hidden AP */
> 3039			memcpy(ssid->data, bi->SSID, bi->SSID_len);
  3040		}
  3041	
  3042		brcmf_dbg(CONN, "bssid: %pM\n", bi->BSSID);
  3043		brcmf_dbg(CONN, "Channel: %d(%d)\n", channel, freq);
  3044		brcmf_dbg(CONN, "Capability: %X\n", notify_capability);
  3045		brcmf_dbg(CONN, "Beacon interval: %d\n", notify_interval);
  3046		brcmf_dbg(CONN, "Signal: %d\n", bss_data.signal);
  3047	
  3048		bss = cfg80211_inform_bss_data(wiphy, &bss_data,
  3049					       CFG80211_BSS_FTYPE_UNKNOWN,
  3050					       (const u8 *)bi->BSSID,
  3051					       0, notify_capability,
  3052					       notify_interval, notify_ie,
  3053					       notify_ielen, GFP_KERNEL);
  3054	
  3055		if (!bss)
  3056			return -ENOMEM;
  3057	
  3058		cfg80211_put_bss(wiphy, bss);
  3059	
  3060		return 0;
  3061	}
  3062
kernel test robot Sept. 23, 2022, 10:59 a.m. UTC | #2
Hi Ian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.0-rc6 next-20220921]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ian-Lin/Fix-connect-p2p-issue-series/20220922-184424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
config: parisc-allyesconfig (https://download.01.org/0day-ci/archive/20220923/202209231808.8r6Ydw4M-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/620f981fff55c74cd1fa86e5b6c177d51344f654
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ian-Lin/Fix-connect-p2p-issue-series/20220922-184424
        git checkout 620f981fff55c74cd1fa86e5b6c177d51344f654
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash drivers/net/wireless/broadcom/brcm80211/brcmfmac/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function 'brcmf_inform_single_bss':
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3039:28: warning: passing argument 1 of 'memcpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    3039 |                 memcpy(ssid->data, bi->SSID, bi->SSID_len);
         |                        ~~~~^~~~~~
   In file included from include/linux/string.h:20,
                    from include/linux/uuid.h:12,
                    from include/linux/mod_devicetable.h:13,
                    from arch/parisc/include/asm/hardware.h:5,
                    from arch/parisc/include/asm/processor.h:17,
                    from arch/parisc/include/asm/spinlock.h:7,
                    from arch/parisc/include/asm/atomic.h:22,
                    from include/linux/atomic.h:7,
                    from arch/parisc/include/asm/bitops.h:13,
                    from include/linux/bitops.h:68,
                    from include/linux/kernel.h:22,
                    from drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:8:
   arch/parisc/include/asm/string.h:9:22: note: expected 'void *' but argument is of type 'const u8 *' {aka 'const unsigned char *'}
       9 | void * memcpy(void * dest,const void *src,size_t count);
         |               ~~~~~~~^~~~


vim +3039 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

  2990	
  2991	static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
  2992					   struct brcmf_bss_info_le *bi)
  2993	{
  2994		struct wiphy *wiphy = cfg_to_wiphy(cfg);
  2995		struct brcmf_pub *drvr = cfg->pub;
  2996		struct cfg80211_bss *bss;
  2997		enum nl80211_band band;
  2998		struct brcmu_chan ch;
  2999		u16 channel;
  3000		u32 freq;
  3001		u16 notify_capability;
  3002		u16 notify_interval;
  3003		u8 *notify_ie;
  3004		size_t notify_ielen;
  3005		struct cfg80211_inform_bss bss_data = {};
  3006		const struct brcmf_tlv *ssid = NULL;
  3007	
  3008		if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
  3009			bphy_err(drvr, "Bss info is larger than buffer. Discarding\n");
  3010			return -EINVAL;
  3011		}
  3012	
  3013		if (!bi->ctl_ch) {
  3014			ch.chspec = le16_to_cpu(bi->chanspec);
  3015			cfg->d11inf.decchspec(&ch);
  3016			bi->ctl_ch = ch.control_ch_num;
  3017		}
  3018		channel = bi->ctl_ch;
  3019	
  3020		if (channel <= CH_MAX_2G_CHANNEL)
  3021			band = NL80211_BAND_2GHZ;
  3022		else
  3023			band = NL80211_BAND_5GHZ;
  3024	
  3025		freq = ieee80211_channel_to_frequency(channel, band);
  3026		bss_data.chan = ieee80211_get_channel(wiphy, freq);
  3027		bss_data.scan_width = NL80211_BSS_CHAN_WIDTH_20;
  3028		bss_data.boottime_ns = ktime_to_ns(ktime_get_boottime());
  3029	
  3030		notify_capability = le16_to_cpu(bi->capability);
  3031		notify_interval = le16_to_cpu(bi->beacon_period);
  3032		notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
  3033		notify_ielen = le32_to_cpu(bi->ie_length);
  3034		bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
  3035	
  3036		ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
  3037		if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
  3038			/* Update SSID for hidden AP */
> 3039			memcpy(ssid->data, bi->SSID, bi->SSID_len);
  3040		}
  3041	
  3042		brcmf_dbg(CONN, "bssid: %pM\n", bi->BSSID);
  3043		brcmf_dbg(CONN, "Channel: %d(%d)\n", channel, freq);
  3044		brcmf_dbg(CONN, "Capability: %X\n", notify_capability);
  3045		brcmf_dbg(CONN, "Beacon interval: %d\n", notify_interval);
  3046		brcmf_dbg(CONN, "Signal: %d\n", bss_data.signal);
  3047	
  3048		bss = cfg80211_inform_bss_data(wiphy, &bss_data,
  3049					       CFG80211_BSS_FTYPE_UNKNOWN,
  3050					       (const u8 *)bi->BSSID,
  3051					       0, notify_capability,
  3052					       notify_interval, notify_ie,
  3053					       notify_ielen, GFP_KERNEL);
  3054	
  3055		if (!bss)
  3056			return -ENOMEM;
  3057	
  3058		cfg80211_put_bss(wiphy, bss);
  3059	
  3060		return 0;
  3061	}
  3062
kernel test robot Sept. 26, 2022, 6:02 a.m. UTC | #3
Hi Ian,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v6.0-rc7 next-20220923]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ian-Lin/Fix-connect-p2p-issue-series/20220922-184424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
config: mips-cu1000-neo_defconfig
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mipsel-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/620f981fff55c74cd1fa86e5b6c177d51344f654
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ian-Lin/Fix-connect-p2p-issue-series/20220922-184424
        git checkout 620f981fff55c74cd1fa86e5b6c177d51344f654
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/net/wireless/broadcom/brcm80211/brcmfmac/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3039:10: error: passing 'const u8[1]' (aka 'const unsigned char[1]') to parameter of type 'void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
                   memcpy(ssid->data, bi->SSID, bi->SSID_len);
                          ^~~~~~~~~~
   arch/mips/include/asm/string.h:17:27: note: passing argument to parameter '__to' here
   extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
                             ^
   1 error generated.


vim +3039 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

  2990	
  2991	static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
  2992					   struct brcmf_bss_info_le *bi)
  2993	{
  2994		struct wiphy *wiphy = cfg_to_wiphy(cfg);
  2995		struct brcmf_pub *drvr = cfg->pub;
  2996		struct cfg80211_bss *bss;
  2997		enum nl80211_band band;
  2998		struct brcmu_chan ch;
  2999		u16 channel;
  3000		u32 freq;
  3001		u16 notify_capability;
  3002		u16 notify_interval;
  3003		u8 *notify_ie;
  3004		size_t notify_ielen;
  3005		struct cfg80211_inform_bss bss_data = {};
  3006		const struct brcmf_tlv *ssid = NULL;
  3007	
  3008		if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
  3009			bphy_err(drvr, "Bss info is larger than buffer. Discarding\n");
  3010			return -EINVAL;
  3011		}
  3012	
  3013		if (!bi->ctl_ch) {
  3014			ch.chspec = le16_to_cpu(bi->chanspec);
  3015			cfg->d11inf.decchspec(&ch);
  3016			bi->ctl_ch = ch.control_ch_num;
  3017		}
  3018		channel = bi->ctl_ch;
  3019	
  3020		if (channel <= CH_MAX_2G_CHANNEL)
  3021			band = NL80211_BAND_2GHZ;
  3022		else
  3023			band = NL80211_BAND_5GHZ;
  3024	
  3025		freq = ieee80211_channel_to_frequency(channel, band);
  3026		bss_data.chan = ieee80211_get_channel(wiphy, freq);
  3027		bss_data.scan_width = NL80211_BSS_CHAN_WIDTH_20;
  3028		bss_data.boottime_ns = ktime_to_ns(ktime_get_boottime());
  3029	
  3030		notify_capability = le16_to_cpu(bi->capability);
  3031		notify_interval = le16_to_cpu(bi->beacon_period);
  3032		notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
  3033		notify_ielen = le32_to_cpu(bi->ie_length);
  3034		bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
  3035	
  3036		ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
  3037		if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
  3038			/* Update SSID for hidden AP */
> 3039			memcpy(ssid->data, bi->SSID, bi->SSID_len);
  3040		}
  3041	
  3042		brcmf_dbg(CONN, "bssid: %pM\n", bi->BSSID);
  3043		brcmf_dbg(CONN, "Channel: %d(%d)\n", channel, freq);
  3044		brcmf_dbg(CONN, "Capability: %X\n", notify_capability);
  3045		brcmf_dbg(CONN, "Beacon interval: %d\n", notify_interval);
  3046		brcmf_dbg(CONN, "Signal: %d\n", bss_data.signal);
  3047	
  3048		bss = cfg80211_inform_bss_data(wiphy, &bss_data,
  3049					       CFG80211_BSS_FTYPE_UNKNOWN,
  3050					       (const u8 *)bi->BSSID,
  3051					       0, notify_capability,
  3052					       notify_interval, notify_ie,
  3053					       notify_ielen, GFP_KERNEL);
  3054	
  3055		if (!bss)
  3056			return -ENOMEM;
  3057	
  3058		cfg80211_put_bss(wiphy, bss);
  3059	
  3060		return 0;
  3061	}
  3062
kernel test robot Sept. 26, 2022, 10:19 a.m. UTC | #4
Hi Ian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.0-rc7 next-20220923]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ian-Lin/Fix-connect-p2p-issue-series/20220922-184424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
config: powerpc-randconfig-s053-20220925
compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/620f981fff55c74cd1fa86e5b6c177d51344f654
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ian-Lin/Fix-connect-p2p-issue-series/20220922-184424
        git checkout 620f981fff55c74cd1fa86e5b6c177d51344f654
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/net/wireless/broadcom/brcm80211/brcmfmac/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3039:24: sparse: sparse: incorrect type in argument 1 (different modifiers) @@     expected void * @@     got unsigned char const * @@
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3039:24: sparse:     expected void *
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3039:24: sparse:     got unsigned char const *

vim +3039 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

  2990	
  2991	static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
  2992					   struct brcmf_bss_info_le *bi)
  2993	{
  2994		struct wiphy *wiphy = cfg_to_wiphy(cfg);
  2995		struct brcmf_pub *drvr = cfg->pub;
  2996		struct cfg80211_bss *bss;
  2997		enum nl80211_band band;
  2998		struct brcmu_chan ch;
  2999		u16 channel;
  3000		u32 freq;
  3001		u16 notify_capability;
  3002		u16 notify_interval;
  3003		u8 *notify_ie;
  3004		size_t notify_ielen;
  3005		struct cfg80211_inform_bss bss_data = {};
  3006		const struct brcmf_tlv *ssid = NULL;
  3007	
  3008		if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
  3009			bphy_err(drvr, "Bss info is larger than buffer. Discarding\n");
  3010			return -EINVAL;
  3011		}
  3012	
  3013		if (!bi->ctl_ch) {
  3014			ch.chspec = le16_to_cpu(bi->chanspec);
  3015			cfg->d11inf.decchspec(&ch);
  3016			bi->ctl_ch = ch.control_ch_num;
  3017		}
  3018		channel = bi->ctl_ch;
  3019	
  3020		if (channel <= CH_MAX_2G_CHANNEL)
  3021			band = NL80211_BAND_2GHZ;
  3022		else
  3023			band = NL80211_BAND_5GHZ;
  3024	
  3025		freq = ieee80211_channel_to_frequency(channel, band);
  3026		bss_data.chan = ieee80211_get_channel(wiphy, freq);
  3027		bss_data.scan_width = NL80211_BSS_CHAN_WIDTH_20;
  3028		bss_data.boottime_ns = ktime_to_ns(ktime_get_boottime());
  3029	
  3030		notify_capability = le16_to_cpu(bi->capability);
  3031		notify_interval = le16_to_cpu(bi->beacon_period);
  3032		notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
  3033		notify_ielen = le32_to_cpu(bi->ie_length);
  3034		bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
  3035	
  3036		ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
  3037		if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
  3038			/* Update SSID for hidden AP */
> 3039			memcpy(ssid->data, bi->SSID, bi->SSID_len);
  3040		}
  3041	
  3042		brcmf_dbg(CONN, "bssid: %pM\n", bi->BSSID);
  3043		brcmf_dbg(CONN, "Channel: %d(%d)\n", channel, freq);
  3044		brcmf_dbg(CONN, "Capability: %X\n", notify_capability);
  3045		brcmf_dbg(CONN, "Beacon interval: %d\n", notify_interval);
  3046		brcmf_dbg(CONN, "Signal: %d\n", bss_data.signal);
  3047	
  3048		bss = cfg80211_inform_bss_data(wiphy, &bss_data,
  3049					       CFG80211_BSS_FTYPE_UNKNOWN,
  3050					       (const u8 *)bi->BSSID,
  3051					       0, notify_capability,
  3052					       notify_interval, notify_ie,
  3053					       notify_ielen, GFP_KERNEL);
  3054	
  3055		if (!bss)
  3056			return -ENOMEM;
  3057	
  3058		cfg80211_put_bss(wiphy, bss);
  3059	
  3060		return 0;
  3061	}
  3062
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 6c37da42e61b..05961ef293da 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -3003,6 +3003,7 @@  static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
 	u8 *notify_ie;
 	size_t notify_ielen;
 	struct cfg80211_inform_bss bss_data = {};
+	const struct brcmf_tlv *ssid = NULL;
 
 	if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
 		bphy_err(drvr, "Bss info is larger than buffer. Discarding\n");
@@ -3032,6 +3033,12 @@  static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,
 	notify_ielen = le32_to_cpu(bi->ie_length);
 	bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
 
+	ssid = brcmf_parse_tlvs(notify_ie, notify_ielen, WLAN_EID_SSID);
+	if (ssid && ssid->data[0] == '\0' && ssid->len == bi->SSID_len) {
+		/* Update SSID for hidden AP */
+		memcpy(ssid->data, bi->SSID, bi->SSID_len);
+	}
+
 	brcmf_dbg(CONN, "bssid: %pM\n", bi->BSSID);
 	brcmf_dbg(CONN, "Channel: %d(%d)\n", channel, freq);
 	brcmf_dbg(CONN, "Capability: %X\n", notify_capability);