diff --git a/src/adapter.c b/src/adapter.c
index 9141773..afe1ff7 100644
--- a/src/adapter.c
+++ b/src/adapter.c
int adapter_connect_list_add(struct btd_adapter *adapter,
struct btd_device *device)
{
+ /*
+ * If the adapter->connect_le device is getting added back to
+ * the connect list it probably means that the connect attempt
+ * failed and hence we should clear this pointer
+ */
+ if (device == adapter->connect_le)
+ adapter->connect_le = NULL;
+
if (g_slist_find(adapter->connect_list, device)) {
DBG("ignoring already added device %s",
device_get_path(device));
void adapter_connect_list_remove(struct btd_adapter *adapter,
struct btd_device *device)
{
+ /*
+ * If the adapter->connect_le device is being removed from the
+ * connect list it means the connection was successful and hence
+ * the pointer should be cleared
+ */
+ if (device == adapter->connect_le)
+ adapter->connect_le = NULL;
+
if (!g_slist_find(adapter->connect_list, device)) {
DBG("device %s is not on the list, ignoring",
device_get_path(device));