Diff between 1ec0a0ca05064bee1a8a2d07b7ec695353947346 and fc07271d7a62cf432e9e0f235de7dbb2f7c6b2ed

Changed Files

File Additions Deletions Status
android/gatt.c +17 -16 modified

Full Patch

diff --git a/android/gatt.c b/android/gatt.c
index 75a80a5..941582a 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2095,31 +2095,32 @@ bool bt_gatt_register(struct ipc *ipc, const bdaddr_t *addr)
 {
 	DBG("");
 
-	bacpy(&adapter_addr, addr);
+	conn_list = queue_new();
+	conn_wait_queue = queue_new();
+	gatt_clients = queue_new();
 
-	hal_ipc = ipc;
+	if (!conn_list || !conn_wait_queue || !gatt_clients) {
+		error("gatt: Failed to allocate memory for queues");
 
-	conn_list = queue_new();
-	if (!conn_list) {
-		error("gatt: Can not create conn queue");
-		return false;
-	}
+		queue_destroy(gatt_clients, NULL);
+		gatt_clients = NULL;
+
+		queue_destroy(conn_list, NULL);
+		conn_list = NULL;
+
+		queue_destroy(conn_wait_queue, NULL);
+		conn_wait_queue = NULL;
 
-	conn_wait_queue = queue_new();
-	if (!conn_wait_queue) {
-		error("gatt: Can not create conn queue");
 		return false;
 	}
 
+	bacpy(&adapter_addr, addr);
+
+	hal_ipc = ipc;
+
 	ipc_register(hal_ipc, HAL_SERVICE_ID_GATT, cmd_handlers,
 						G_N_ELEMENTS(cmd_handlers));
 
-	gatt_clients = queue_new();
-	if (!gatt_clients) {
-		error("gatt: Cannot allocate gatt_clients");
-		return false;
-	}
-
 	return true;
 }