mac80211: backport brcmfmac changes from 2016-09-26
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 319-0016-brcmfmac-fix-pmksa-bssid-usage.patch
1 From 7703773ef1d85b40433902a8da20167331597e4a Mon Sep 17 00:00:00 2001
2 From: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
3 Date: Tue, 23 Aug 2016 11:37:17 +0200
4 Subject: [PATCH] brcmfmac: fix pmksa->bssid usage
5
6 The struct cfg80211_pmksa defines its bssid field as:
7
8 const u8 *bssid;
9
10 contrary to struct brcmf_pmksa, which uses:
11
12 u8 bssid[ETH_ALEN];
13
14 Therefore in brcmf_cfg80211_del_pmksa(), &pmksa->bssid takes the address
15 of this field (of type u8**), not the one of its content (which would be
16 u8*). Remove the & operator to make brcmf_dbg("%pM") and memcmp()
17 behave as expected.
18
19 This bug have been found using a custom static checker (which checks the
20 usage of %p... attributes at build time). It has been introduced in
21 commit 6c404f34f2bd ("brcmfmac: Cleanup pmksa cache handling code"),
22 which replaced pmksa->bssid by &pmksa->bssid while refactoring the code,
23 without modifying struct cfg80211_pmksa definition.
24
25 Replace &pmk[i].bssid with pmk[i].bssid too to make the code clearer,
26 this change does not affect the semantic.
27
28 Fixes: 6c404f34f2bd ("brcmfmac: Cleanup pmksa cache handling code")
29 Cc: stable@vger.kernel.org
30 Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
31 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
32 ---
33 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 4 ++--
34 1 file changed, 2 insertions(+), 2 deletions(-)
35
36 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
37 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
38 @@ -3880,11 +3880,11 @@ brcmf_cfg80211_del_pmksa(struct wiphy *w
39 if (!check_vif_up(ifp->vif))
40 return -EIO;
41
42 - brcmf_dbg(CONN, "del_pmksa - PMK bssid = %pM\n", &pmksa->bssid);
43 + brcmf_dbg(CONN, "del_pmksa - PMK bssid = %pM\n", pmksa->bssid);
44
45 npmk = le32_to_cpu(cfg->pmk_list.npmk);
46 for (i = 0; i < npmk; i++)
47 - if (!memcmp(&pmksa->bssid, &pmk[i].bssid, ETH_ALEN))
48 + if (!memcmp(pmksa->bssid, pmk[i].bssid, ETH_ALEN))
49 break;
50
51 if ((npmk > 0) && (i < npmk)) {