hci_clear_bit(BDADDR_LE_RANDOM, &adapter->discovery_type);
if (adapter->le_discovering == true) {
- struct watch_client *client;
- client = adapter->le_discovery_list->data;
+ if (adapter->le_discovery_list) {
+ struct watch_client *client;
+
+ client = adapter->le_discovery_list->data;
+ g_dbus_remove_watch(dbus_conn, client->watch);
+ }
+
adapter->le_discovering = false;
- g_dbus_remove_watch(dbus_conn, client->watch);
}
} else {
hci_set_bit(BDADDR_LE_PUBLIC, &adapter->discovery_type);
static void stop_le_discovery_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
- struct watch_client *client = user_data;
- struct btd_adapter *adapter = client->adapter;
+ struct btd_adapter *adapter = user_data;
+ struct watch_client *client;
DBusMessage *reply;
DBG("status 0x%02x", status);
+ /* Is there are no clients the discovery must have been stopped while
+ * discovery command was pending.
+ */
+ if (!adapter->le_discovery_list)
+ return;
+
+ client = adapter->le_discovery_list->data;
+
if (status != MGMT_STATUS_SUCCESS) {
if (client->msg) {
reply = btd_error_busy(client->msg);
mgmt_send(adapter->mgmt, MGMT_OP_STOP_LE_DISCOVERY,
adapter->dev_id, sizeof(cp), &cp,
- stop_discovery_complete, client, NULL);
+ stop_le_discovery_complete, adapter, NULL);
}
#ifdef TIZEN_FEATURE_PLATFROM_SCAN_FILTER
DBG("cp.type %d", cp.type);
mgmt_send(adapter->mgmt, MGMT_OP_STOP_LE_DISCOVERY,
adapter->dev_id, sizeof(cp), &cp,
- stop_le_discovery_complete, client, NULL);
+ stop_le_discovery_complete, adapter, NULL);
client->msg = dbus_message_ref(msg);
return NULL;