Diff between cbce18be2232b2725d08caaff90333f966150301 and 8da3f380860e104e371a9e20bdb2b1fe7746abf6

Changed Files

File Additions Deletions Status
android/a2dp.c +8 -3 modified

Full Patch

diff --git a/android/a2dp.c b/android/a2dp.c
index 731fa16..8cff535 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -171,10 +171,15 @@ static void a2dp_device_free(void *data)
 
 	setup_remove_all_by_dev(dev);
 
-	devices = g_slist_remove(devices, dev);
 	g_free(dev);
 }
 
+static void a2dp_device_remove(struct a2dp_device *dev)
+{
+	devices = g_slist_remove(devices, dev);
+	a2dp_device_free(dev);
+}
+
 static struct a2dp_device *a2dp_device_new(const bdaddr_t *dst)
 {
 	struct a2dp_device *dev;
@@ -229,7 +234,7 @@ static void bt_a2dp_notify_state(struct a2dp_device *dev, uint8_t state)
 
 	bt_avrcp_disconnect(&dev->dst);
 
-	a2dp_device_free(dev);
+	a2dp_device_remove(dev);
 }
 
 static void bt_audio_notify_state(struct a2dp_setup *setup, uint8_t state)
@@ -579,7 +584,7 @@ static void bt_a2dp_connect(const void *buf, uint16_t len)
 
 	dev = a2dp_device_new(&dst);
 	if (!a2dp_device_connect(dev, signaling_connect_cb)) {
-		a2dp_device_free(dev);
+		a2dp_device_remove(dev);
 		status = HAL_STATUS_FAILED;
 		goto failed;
 	}