wlan: Prevent potential race condition during adapter access

Currently in the driver, there is a possiblity of a race condition
between hdd_wlan_suspend and del_virtual_interface. In hdd_wlan_suspend,
the driver iterates over all the adapters and performs designated action
for each. During the process of iteration, there is no lock to prevent
race conditions. In the scenario when a del_virtual_interface comes
while this iteration is in progress, it can happen that the adapter is
cleared in the del_virtual interface path and the same is tried to be
accessed in the hdd_wlan_suspend.

To avoid this possible scenario, lock the iteration with dev_hold which
prevents the unregistration of the netdev. Also call hdd_deinit_adapter
in the del_interface path which clears the timer that is responsible for
calling the suspend call.

Change-Id: Iebf68287c38c8babb0d91b4a11d4d01d53ae8ddc
CRs-Fixed: 2512741
diff --git a/CORE/HDD/src/wlan_hdd_early_suspend.c b/CORE/HDD/src/wlan_hdd_early_suspend.c
index f8f0da2..e68aa7a 100644
--- a/CORE/HDD/src/wlan_hdd_early_suspend.c
+++ b/CORE/HDD/src/wlan_hdd_early_suspend.c
@@ -1677,6 +1677,7 @@
            pAdapterNode = pNext;
            continue;
        }
+       dev_hold(pAdapter->dev);
        /* Avoid multiple enter/exit BMPS in this while loop using
         * hdd_enter_bmps flag
         */
@@ -1721,6 +1722,7 @@
                  __func__, ret);
        }
        status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
+       dev_put(pAdapter->dev);
        pAdapterNode = pNext;
    }
 
diff --git a/CORE/HDD/src/wlan_hdd_p2p.c b/CORE/HDD/src/wlan_hdd_p2p.c
index dfb9083..e3ab8b4 100644
--- a/CORE/HDD/src/wlan_hdd_p2p.c
+++ b/CORE/HDD/src/wlan_hdd_p2p.c
@@ -2547,6 +2547,7 @@
 {
 	wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes);
 	hdd_stop_adapter(hdd_ctx, adapter, VOS_TRUE);
+	hdd_deinit_adapter(hdd_ctx, adapter, TRUE);
 	hdd_close_adapter(hdd_ctx, adapter, rtnl_held);
 }