wlan: Fix hdd_ctx validation in __hdd_stop

cld to prima propagation.
During driver unload, hdd_wlan_exit is called which cleans
all adapters and nullifies hdd_ctx struct after marking
wlan interfaces down. __hdd_stop is called as part of driver
rmmod or ifconfig down by the kernel. If it is called during
hdd_wlan_exit it can return without shutting down tx queue because of
wlan_hdd_validate_context which always return false during
driver unload.Tx queues are closed beforehand in hdd_wlan_exit
to avoid any race conditions.

Change-Id: I570ee1b24b5e8fb1408e39498c99d1238dbe34ec
CRs-fixed: 986526
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index 892fe16..9a8424a 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -7061,6 +7061,7 @@
       /* after uninit our adapter structure will no longer be valid */
       pAdapter->dev = NULL;
       pAdapter->magic = 0;
+      pAdapter->pHddCtx = NULL;
    } while (0);
 
    EXIT();
@@ -7809,6 +7810,32 @@
 
    return eHAL_STATUS_SUCCESS;
 }
+/**
+ * hdd_close_tx_queues() - close tx queues
+ * @hdd_ctx: hdd global context
+ *
+ * Return: None
+ */
+static void hdd_close_tx_queues(hdd_context_t *hdd_ctx)
+{
+   VOS_STATUS status;
+   hdd_adapter_t *adapter;
+   hdd_adapter_list_node_t *adapter_node = NULL, *next_adapter = NULL;
+   /* Not validating hdd_ctx as it's already done by the caller */
+   ENTER();
+   status = hdd_get_front_adapter(hdd_ctx, &adapter_node);
+   while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
+      adapter = adapter_node->pAdapter;
+      if (adapter && adapter->dev) {
+          netif_tx_disable (adapter->dev);
+          netif_carrier_off(adapter->dev);
+      }
+      status = hdd_get_next_adapter(hdd_ctx, adapter_node,
+                                    &next_adapter);
+      adapter_node = next_adapter;
+   }
+   EXIT();
+}
 
 VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter )
 {
@@ -10339,6 +10366,7 @@
    //Clean up HDD Nlink Service
    send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
 
+   hdd_close_tx_queues(pHddCtx);
    wlan_free_fwr_mem_dump_buffer();
    memdump_deinit();