wlan: Clear any key values in the memory.

Clear the key values from the memory when session is
being removed and/or when no need of the key values.

Change-Id: I5914d6521855c021d1d9e2f268771a4113e5f6ef
CRs-Fixed: 737934
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 6d1252f..28caca2 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -5181,6 +5181,11 @@
                                                 __LINE__, status );
         pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
     }
+    /* Need to clear any trace of key value in the memory.
+     * Thus zero out the memory even though it is local
+     * variable.
+     */
+    vos_mem_zero(&setKey, sizeof(setKey));
 }
 #endif /* FEATURE_WLAN_WAPI*/
 
@@ -7942,7 +7947,8 @@
         default:
             hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
                     __func__, params->cipher);
-            return -EOPNOTSUPP;
+            status = -EOPNOTSUPP;
+            goto end;
     }
 
     hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
@@ -7983,13 +7989,14 @@
         {
             hddLog(VOS_TRACE_LEVEL_ERROR,
                     "%s: sme_RoamSetKey failed, returned %d", __func__, status);
-            return -EINVAL;
+            status = -EINVAL;
+            goto end;
         }
         /*Save the keys here and call sme_RoamSetKey for setting
           the PTK after peer joins the IBSS network*/
         vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
                                     &setKey, sizeof(tCsrRoamSetKey));
-        return status;
+        goto end;
     }
     if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
            (pAdapter->device_mode == WLAN_HDD_P2P_GO))
@@ -8008,7 +8015,8 @@
 
                 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
 
-                return -EINVAL;
+                status = -EINVAL;
+                goto end;
             }
 
             status = WLANSAP_SetKeySta( pVosContext, &setKey);
@@ -8018,6 +8026,8 @@
                 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
                         "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
                         __LINE__, status );
+                status = -EINVAL;
+                goto end;
             }
         }
 
@@ -8086,7 +8096,8 @@
 
             pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
 
-            return -EINVAL;
+            status = -EINVAL;
+            goto end;
 
         }
 
@@ -8099,13 +8110,15 @@
         {
            hddLog(VOS_TRACE_LEVEL_INFO_MED,
                   "%s: Update PreAuth Key success", __func__);
-           return 0;
+           status = 0;
+           goto end;
         }
         else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
         {
            hddLog(VOS_TRACE_LEVEL_ERROR,
                   "%s: Update PreAuth Key failed", __func__);
-           return -EINVAL;
+           status = -EINVAL;
+           goto end;
         }
 #endif /* WLAN_FEATURE_VOWIFI_11R */
 
@@ -8118,7 +8131,8 @@
             hddLog(VOS_TRACE_LEVEL_ERROR,
                     "%s: sme_RoamSetKey failed, returned %d", __func__, status);
             pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
-            return -EINVAL;
+            status = -EINVAL;
+            goto end;
         }
 
 
@@ -8155,12 +8169,20 @@
                         "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
                         __func__, status);
                 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
-                return -EINVAL;
+                status = -EINVAL;
+                goto end;
             }
         }
     }
 
-    return 0;
+end:
+    /* Need to clear any trace of key value in the memory.
+     * Thus zero out the memory even though it is local
+     * variable.
+     */
+    vos_mem_zero(&setKey, sizeof(setKey));
+
+    return status;
 }
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
@@ -14080,6 +14102,13 @@
             VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
                     "%s: sme_SetGTKOffload failed, returned %d",
                     __func__, status);
+
+           /* Need to clear any trace of key value in the memory.
+            * Thus zero out the memory even though it is local
+            * variable.
+            */
+            vos_mem_zero(&hddGtkOffloadReqParams,
+                          sizeof(hddGtkOffloadReqParams));
             return status;
         }
         VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
@@ -14092,6 +14121,13 @@
                 __func__);
     }
 
+    /* Need to clear any trace of key value in the memory.
+     * Thus zero out the memory even though it is local
+     * variable.
+     */
+    vos_mem_zero(&hddGtkOffloadReqParams,
+                  sizeof(hddGtkOffloadReqParams));
+
     return eHAL_STATUS_SUCCESS;
 }