WLAN: Fix for PMK Cache

Fix to address PMK cache corruption when the supplicant does not provide
a BSSID in the connect request
CRs-fixed:481602

Change-Id: I69c8f114f17a24eaf4ec222b261d55ab0d1c7b9b
diff --git a/CORE/HDD/src/wlan_hdd_assoc.c b/CORE/HDD/src/wlan_hdd_assoc.c
index 81162c9..ada1011 100644
--- a/CORE/HDD/src/wlan_hdd_assoc.c
+++ b/CORE/HDD/src/wlan_hdd_assoc.c
@@ -2738,6 +2738,7 @@
     tANI_U8 *pRsnIe;
     tANI_U16 RSNIeLen;
     tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
+    v_BOOL_t updatePMKCache = FALSE;
 
     /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
        flag to 0 */
@@ -2790,10 +2791,11 @@
             {
                 break;
             }
-            if ( hdd_IsMACAddrNULL( (u_char *) pBssid , sizeof( (char *) pBssid)))
+            if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
             {
                 break;
             }
+            updatePMKCache = TRUE;
             // For right now, I assume setASSOCIATE() has passed in the bssid.
             vos_mem_copy(PMKIDCache[i].BSSID,
                             pBssid, ETHER_ADDR_LEN);
@@ -2801,13 +2803,17 @@
                             dot11RSNIE.pmkid[i],
                             CSR_RSN_PMKID_SIZE);
         }
-        // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
-        hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
+
+        if (updatePMKCache)
+        {
+            // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
+            hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
                                                                             __func__, i );
-        // Finally set the PMKSA ID Cache in CSR
-        result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
-                                        PMKIDCache,
-                                        dot11RSNIE.pmkid_count );
+            // Finally set the PMKSA ID Cache in CSR
+            result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
+                                           PMKIDCache,
+                                           dot11RSNIE.pmkid_count );
+        }
     }
     else if (gen_ie[0] == DOT11F_EID_WPA)
     {
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index aa3cbb1..933f5a8 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -4853,6 +4853,10 @@
             vos_mem_copy((void *)(pWextState->req_bssId), bssid,
                     WNI_CFG_BSSID_LEN);
         }
+        else
+        {
+            vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
+        }
 
         if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
                 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))