wlan: Abort scan for SSID if deauth is received from supplicant.

During connection if AP is not found in scan list, driver tries
to scan for the ssid (eCsrScanForSsid) and if AP is found,
the connect cmd is started.

During this scan if Disconnect comes from supplicant, as there is
no ongoing connect command and sme is not in connected state, the
disconnect command is dropped in SME and hdd is indicated success.
This leads to HDD waiting on the event disconnect_comp_var and
connState to eConnectionState_Disconnecting.

After this if supplicant send connect and as HDD is in
disconnecting state it will again wait for disconnect_comp_var
and return failure after timeout and this will continue and user
will not able to connect.

If disconnect is received during eCsrScanForSsid abort/dequeue
the eCsrScanForSsid in SME and in HDD set the connState to
eConnectionState_NotConnected and set disconnect_comp_var
complete.
CRs-Fixed: 682691

Change-Id: I3b689dc7ffd586d28c5f852614dd3605985ba4f3
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index bcbf055..9f0a319 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -10243,6 +10243,7 @@
     int status;
     hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
     hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+    long ret;
 
     status = wlan_hdd_validate_context(pHddCtx);
 
@@ -10264,29 +10265,39 @@
 
     status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
                                  pAdapter->sessionId, reason);
+     if(eHAL_STATUS_CMD_NOT_QUEUED == status)
+     {
+        hddLog(VOS_TRACE_LEVEL_INFO,
+             FL("status = %d, already disconnected"),
+                     (int)status );
 
-    if ( 0 != status )
+    }
+    else if ( 0 != status )
     {
         hddLog(VOS_TRACE_LEVEL_ERROR,
                "%s csrRoamDisconnect failure, returned %d",
                __func__, (int)status );
         return -EINVAL;
     }
-    status = wait_for_completion_interruptible_timeout(
+    ret = wait_for_completion_interruptible_timeout(
                 &pAdapter->disconnect_comp_var,
                 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
-    if (!status)
+    if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
     {
         hddLog(VOS_TRACE_LEVEL_ERROR,
               "%s: Failed to disconnect, timed out", __func__);
         return -ETIMEDOUT;
     }
-    else if (status == -ERESTARTSYS)
+    else if (ret == -ERESTARTSYS)
     {
         hddLog(VOS_TRACE_LEVEL_ERROR,
                "%s: Failed to disconnect, wait interrupted", __func__);
-        return status;
+        return ret;
     }
+    VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
+              FL("Set HDD connState to eConnectionState_NotConnected"));
+    pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
+
     /*stop tx queues*/
     netif_tx_disable(pAdapter->dev);
     netif_carrier_off(pAdapter->dev);