Ignore  TDLS teardown when the peer is not connected

Do not attempt to send TDLS teardown when the peer does not exist
or the peer link status is not CONNECTED.

Change-Id: Ie2aa4498b4169bd8aa197c0b14bc40e3f27925e6
CRs-Fixed: 475968
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 45ea9cf..736d560 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -7039,14 +7039,19 @@
     responder = 0;
     if (SIR_MAC_TDLS_TEARDOWN == action_code)
     {
-       responder = wlan_hdd_tdls_get_responder(pAdapter, peerMac);
-       if(-1 == responder)
+
+       hddTdlsPeer_t *pTdlsPeer;
+       pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac);
+
+       if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
+            responder = pTdlsPeer->is_responder;
+       else
        {
-            VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
-                     "%s: " MAC_ADDRESS_STR " peer doesn't exist dialog_token %d status %d, len = %d",
-                     "tdls_mgmt", MAC_ADDR_ARRAY(peer),
-                      dialog_token, status_code, len);
-            return -EPERM;
+           VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                    "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
+                    __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
+                     dialog_token, status_code, len);
+           return -EPERM;
        }
     }