net: wireless: bcm4329: Fix GCC 4.6 warning
Dan Willemsen [Thu, 8 Mar 2012 02:11:54 +0000 (18:11 -0800)]
This module has -Werror turned on, so this was causing the build to
break on GCC 4.6:

drivers/net/wireless/bcm4329/wl_iw.c: In function 'wl_iw_set_pmksa':
drivers/net/wireless/bcm4329/wl_iw.c:5149:5: error: array subscript is above array bounds [-Werror=array-bounds]
drivers/net/wireless/bcm4329/wl_iw.c:5152:5: error: array subscript is above array bounds [-Werror=array-bounds]

It's a partial 'backport' of a change made to the bcmdhd driver:

commit 09a8dc7361d0e603d9935ec7f736fabaa2e6dc7a
net: wireless: bcmdhd: Combined P2P fix

Change-Id: Ie62ad82f884c213553772ac91eaf85e17a807503
Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-on: http://git-master/r/88694
GVS: Gerrit_Virtual_Submit
Reviewed-by: Stephen Warren <swarren@nvidia.com>

drivers/net/wireless/bcm4329/wl_iw.c

index 434e584..e71ab64 100644 (file)
@@ -5109,6 +5109,7 @@ wl_iw_set_pmksa(
        uint i;
        int ret = 0;
        char eabuf[ETHER_ADDR_STR_LEN];
+       pmkid_t * pmkid_array = pmkid_list.pmkids.pmkid;
 
        WL_WSEC(("%s: SIOCSIWPMKSA\n", dev->name));
        CHECK_EXTRA_FOR_NULL(extra);
@@ -5139,18 +5140,18 @@ wl_iw_set_pmksa(
                }
 
                for (i = 0; i < pmkid_list.pmkids.npmkid; i++)
-                       if (!bcmp(&iwpmksa->bssid.sa_data[0], &pmkid_list.pmkids.pmkid[i].BSSID,
+                       if (!bcmp(&iwpmksa->bssid.sa_data[0], &pmkid_array[i].BSSID,
                                ETHER_ADDR_LEN))
                                break;
 
                if ((pmkid_list.pmkids.npmkid > 0) && (i < pmkid_list.pmkids.npmkid)) {
-                       bzero(&pmkid_list.pmkids.pmkid[i], sizeof(pmkid_t));
+                       bzero(&pmkid_array[i], sizeof(pmkid_t));
                        for (; i < (pmkid_list.pmkids.npmkid - 1); i++) {
-                               bcopy(&pmkid_list.pmkids.pmkid[i+1].BSSID,
-                                       &pmkid_list.pmkids.pmkid[i].BSSID,
+                               bcopy(&pmkid_array[i+1].BSSID,
+                                       &pmkid_array[i].BSSID,
                                        ETHER_ADDR_LEN);
-                               bcopy(&pmkid_list.pmkids.pmkid[i+1].PMKID,
-                                       &pmkid_list.pmkids.pmkid[i].PMKID,
+                               bcopy(&pmkid_array[i+1].PMKID,
+                                       &pmkid_array[i].PMKID,
                                        WPA2_PMKID_LEN);
                        }
                        pmkid_list.pmkids.npmkid--;
@@ -5161,14 +5162,14 @@ wl_iw_set_pmksa(
 
        else if (iwpmksa->cmd == IW_PMKSA_ADD) {
                for (i = 0; i < pmkid_list.pmkids.npmkid; i++)
-                       if (!bcmp(&iwpmksa->bssid.sa_data[0], &pmkid_list.pmkids.pmkid[i].BSSID,
+                       if (!bcmp(&iwpmksa->bssid.sa_data[0], &pmkid_array[i].BSSID,
                                ETHER_ADDR_LEN))
                                break;
                if (i < MAXPMKID) {
                        bcopy(&iwpmksa->bssid.sa_data[0],
-                               &pmkid_list.pmkids.pmkid[i].BSSID,
+                               &pmkid_array[i].BSSID,
                                ETHER_ADDR_LEN);
-                       bcopy(&iwpmksa->pmkid[0], &pmkid_list.pmkids.pmkid[i].PMKID,
+                       bcopy(&iwpmksa->pmkid[0], &pmkid_array[i].PMKID,
                                WPA2_PMKID_LEN);
                        if (i == pmkid_list.pmkids.npmkid)
                                pmkid_list.pmkids.npmkid++;
@@ -5181,10 +5182,10 @@ wl_iw_set_pmksa(
                        uint k;
                        k = pmkid_list.pmkids.npmkid;
                        WL_WSEC(("wl_iw_set_pmksa,IW_PMKSA_ADD - PMKID: %s = ",
-                               bcm_ether_ntoa(&pmkid_list.pmkids.pmkid[k].BSSID,
+                               bcm_ether_ntoa(&pmkid_array[k].BSSID,
                                eabuf)));
                        for (j = 0; j < WPA2_PMKID_LEN; j++)
-                               WL_WSEC(("%02x ", pmkid_list.pmkids.pmkid[k].PMKID[j]));
+                               WL_WSEC(("%02x ", pmkid_array[k].PMKID[j]));
                        WL_WSEC(("\n"));
                }
        }
@@ -5192,10 +5193,10 @@ wl_iw_set_pmksa(
        for (i = 0; i < pmkid_list.pmkids.npmkid; i++) {
                uint j;
                WL_WSEC(("PMKID[%d]: %s = ", i,
-                       bcm_ether_ntoa(&pmkid_list.pmkids.pmkid[i].BSSID,
+                       bcm_ether_ntoa(&pmkid_array[i].BSSID,
                        eabuf)));
                for (j = 0; j < WPA2_PMKID_LEN; j++)
-                       WL_WSEC(("%02x ", pmkid_list.pmkids.pmkid[i].PMKID[j]));
+                       WL_WSEC(("%02x ", pmkid_array[i].PMKID[j]));
                WL_WSEC(("\n"));
        }
        WL_WSEC(("\n"));