Fix race condition for SAP+STA concurrency

In case of SAP+STA concurrency, the wext interface gets used.
This can cause a race condition between the context in which the
wext ioctl is called and the MC thread.

Change-Id: If81d5404b34b59f0f8add90678da0d0398755b2f
CRs-fixed: 457475
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index 747a594..ed9862f 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -556,7 +556,6 @@
             sapCleanupChannelList();
 
             pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
-            vos_event_set(&pHostapdState->vosEvent);
             goto stopbss;
         case eSAP_STA_SET_KEY_EVENT:
             //TODO: forward the message to hostapd once implementtation is done for now just print
@@ -863,6 +862,12 @@
         /* reclaim all resources allocated to the BSS */
         hdd_softap_stop_bss(pHostapdAdapter);
 
+        /* once the event is set, structure dev/pHostapdAdapter should
+         * not be touched since they are now subject to being deleted
+         * by another thread */
+        if (eSAP_STOP_BSS_EVENT == sapEvent)
+            vos_event_set(&pHostapdState->vosEvent);
+
         /* notify userspace that the BSS has stopped */
         memset(&we_custom_event, '\0', sizeof(we_custom_event));
         memcpy(&we_custom_event, stopBssEvent, event_len);