wlan: Fix missing sta_id hash attach in ap mode

Sta_id attach to mac address hash is expected to be done after AP mode
initialization. But it is missing in few scenarios. This is resulting
in STA connection failure to SAP.

To resolve this, attach sta_id to mac address hash as part of ap mode
initialization.

Change-Id: If039b201af9806873aa6751caf7bb455275760d6
CRs-Fixed: 2825333
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 541af37..138ce72 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -12790,14 +12790,6 @@
 		}
                 hdd_set_conparam(1);
 
-                status = hdd_sta_id_hash_attach(pAdapter);
-                if (VOS_STATUS_SUCCESS != status)
-                {
-                    hddLog(VOS_TRACE_LEVEL_ERROR,
-                           FL("Failed to initialize hash for AP"));
-                    return -EINVAL;
-                }
-
                 /*interface type changed update in wiphy structure*/
                 if(wdev)
                 {
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index c2d917e..8115be8 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -5556,6 +5556,15 @@
                                 ini_cfg->apEndChannelNum,
                                 ini_cfg->apOperatingBand);
     }
+
+    status = hdd_sta_id_hash_attach(pAdapter);
+    if (VOS_STATUS_SUCCESS != status)
+    {
+	    hddLog(VOS_TRACE_LEVEL_ERROR,
+			    FL("Failed to initialize hash for AP"));
+	    goto error_wmm_init;
+    }
+
    /* Action frame registered in one adapter which will
     * applicable to all interfaces
     */
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index 67d86ce..8faebe9 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -10113,14 +10113,6 @@
 
          hdd_initialize_adapter_common(pAdapter);
 
-         status = hdd_sta_id_hash_attach(pAdapter);
-         if (VOS_STATUS_SUCCESS != status)
-         {
-             hddLog(VOS_TRACE_LEVEL_FATAL,
-                    FL("failed to attach hash for session %d"), session_type);
-             goto err_free_netdev;
-         }
-
          status = hdd_register_hostapd( pAdapter, rtnl_held );
          if( VOS_STATUS_SUCCESS != status )
          {
@@ -11690,12 +11682,6 @@
          case WLAN_HDD_SOFTAP:
             if (pHddCtx->cfg_ini->sap_internal_restart) {
                 hdd_init_ap_mode(pAdapter, true);
-                status = hdd_sta_id_hash_attach(pAdapter);
-                if (VOS_STATUS_SUCCESS != status)
-                {
-                    hddLog(VOS_TRACE_LEVEL_FATAL,
-                         FL("failed to attach hash for"));
-                }
             }
             break;