Diff between 14454aa5dac746d8428731aab7cd9b0632c493d1 and be7400b4db133b696edd2dc3c68e633368a50efe

Changed Files

File Additions Deletions Status
src/shared/gatt-client.c +7 -9 modified

Full Patch

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 12c9b2f..1acd34f 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -511,6 +511,7 @@ next:
 
 		util_debug(client->debug_callback, client->debug_data,
 				"Failed to start characteristic discovery");
+		discovery_op_unref(op);
 		goto failed;
 	}
 
@@ -527,11 +528,11 @@ next:
 
 	util_debug(client->debug_callback, client->debug_data,
 					"Failed to start included discovery");
+	discovery_op_unref(op);
 
 failed:
 	op->success = false;
 	op->complete_func(op, false, att_ecode);
-	discovery_op_unref(op);
 }
 
 struct chrc {
@@ -586,11 +587,8 @@ static bool discover_descs(struct discovery_op *op, bool *discovering)
 
 		util_debug(client->debug_callback, client->debug_data,
 					"Failed to start descriptor discovery");
+		discovery_op_unref(op);
 
-		/*
-		 * discovery_op_unref done in discover_chrcs_cb
-		 * and discover_descs_cb functions
-		 */
 		goto failed;
 	}
 
@@ -682,6 +680,7 @@ next:
 
 	util_debug(client->debug_callback, client->debug_data,
 				"Failed to start characteristic discovery");
+	discovery_op_unref(op);
 
 failed:
 	success = false;
@@ -689,7 +688,6 @@ failed:
 done:
 	op->success = success;
 	op->complete_func(op, success, att_ecode);
-	discovery_op_unref(op);
 }
 
 static void discover_chrcs_cb(bool success, uint8_t att_ecode,
@@ -783,6 +781,7 @@ next:
 
 	util_debug(client->debug_callback, client->debug_data,
 				"Failed to start characteristic discovery");
+	discovery_op_unref(op);
 
 failed:
 	success = false;
@@ -790,7 +789,6 @@ failed:
 done:
 	op->success = success;
 	op->complete_func(op, success, att_ecode);
-	discovery_op_unref(op);
 }
 
 static void discover_secondary_cb(bool success, uint8_t att_ecode,
@@ -878,11 +876,11 @@ next:
 
 	util_debug(client->debug_callback, client->debug_data,
 				"Failed to start included services discovery");
+	discovery_op_unref(op);
 
 done:
 	op->success = success;
 	op->complete_func(op, success, att_ecode);
-	discovery_op_unref(op);
 }
 
 static void discover_primary_cb(bool success, uint8_t att_ecode,
@@ -945,12 +943,12 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
 
 	util_debug(client->debug_callback, client->debug_data,
 				"Failed to start secondary service discovery");
+	discovery_op_unref(op);
 	success = false;
 
 done:
 	op->success = success;
 	op->complete_func(op, success, att_ecode);
-	discovery_op_unref(op);
 }
 
 static void notify_client_ready(struct bt_gatt_client *client, bool success,