wlan: Fix NULL pointer dereference in wlan_hdd_tdls_add_station()

Check for the StaParams pointer is not NULL before passing it to
sme_ChangeTdlsPeerSta(). Where we are dereferencing this pointer.

CRs-Fixed: 470188
Change-Id: Iceeecfa7b04e0882f84a6792b605cc966a730bb4
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 2a906d8..0ec9a0e 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -2778,7 +2778,7 @@
 
     ENTER();
 
-    if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini || NULL == StaParams)
+    if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
     {
         VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
                 "Invalid arguments");
@@ -2859,6 +2859,7 @@
         wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
 
     /* debug code */
+    if (NULL != StaParams)
     {
         VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
                   "%s: TDLS Peer Parameters.", __func__);
@@ -2883,6 +2884,12 @@
                           "[%d]: %x ", i, StaParams->supported_rates[i]);
         }
     }  /* end debug code */
+    else if ((1 == update) && (NULL == StaParams))
+    {
+        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                   "%s : update is true, but staParams is NULL. Error!", __func__);
+        return -EPERM;
+    }
 
     INIT_COMPLETION(pAdapter->tdls_add_station_comp);