return true;
}
+static struct bt_gatt_client *
+bt_gatt_client_ref_safe(struct bt_gatt_client *client)
+{
+ if (!client || !client->ref_count)
+ return NULL;
+
+ return bt_gatt_client_ref(client);
+}
+
static void notify_client_idle(struct bt_gatt_client *client)
{
- bt_gatt_client_ref(client);
+ client = bt_gatt_client_ref_safe(client);
+ if (!client)
+ return;
queue_remove_all(client->idle_cbs, idle_notify, NULL, idle_destroy);
{
const struct queue_entry *entry;
- if (client->ready)
+ client = bt_gatt_client_ref_safe(client);
+ if (!client)
return;
- bt_gatt_client_ref(client);
+ if (client->ready)
+ goto done;
+
client->ready = success;
if (client->parent)
notify_client_ready(clone, success, att_ecode);
}
+done:
bt_gatt_client_unref(client);
}