SDP: Only start discovery once

Bug: 174052148
Test: pair with headphones
Tag: #security
Change-Id: I1d014a7b793bb1b66e26652f6696499ea36a6510
(cherry picked from commit cfa5a74ea90a09e1c7413a25f04332ee2d1e3f21)
Merged-In: I1d014a7b793bb1b66e26652f6696499ea36a6510
(cherry picked from commit f0994f6e4723eddaa617b68139f064d945d9389e)
diff --git a/bta/ag/bta_ag_sdp.cc b/bta/ag/bta_ag_sdp.cc
index 88b3bdb..dd9ec3c 100644
--- a/bta/ag/bta_ag_sdp.cc
+++ b/bta/ag/bta_ag_sdp.cc
@@ -34,6 +34,7 @@
 #include "bta_sys.h"
 #include "btif_config.h"
 #include "btm_api.h"
+#include "osi/include/log.h"
 #include "osi/include/osi.h"
 #include "sdp_api.h"
 #include "stack/include/btu.h"
@@ -477,6 +478,12 @@
     }
   }
 
+  if (p_scb->p_disc_db != nullptr) {
+    android_errorWriteLog(0x534e4554, "174052148");
+    APPL_TRACE_ERROR("Discovery already in progress... returning.");
+    return;
+  }
+
   /* allocate buffer for sdp database */
   p_scb->p_disc_db = (tSDP_DISCOVERY_DB*)osi_malloc(BTA_AG_DISC_BUF_SIZE);
   /* set up service discovery database; attr happens to be attr_list len */