Bluetooth: Audio: Add missing error checks for calls to bt_gatt_subscribe

Several places the LE Audio clients called bt_gatt_subscribe without
checking the return value, which could cause some issues in the worst
case, and in the best case, cause some unexpected behavior.

Some implementations had a bit more updating to handle the new
behavior.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2024-01-15 17:49:10 +01:00 committed by Maureen Helm
commit 922ac3c7c1
8 changed files with 65 additions and 20 deletions

View file

@ -1297,7 +1297,13 @@ static uint8_t discover_otc_char_func(struct bt_conn *conn,
sub_params->value_handle = chrc->value_handle;
sub_params->notify = bt_ots_client_indicate_handler;
bt_gatt_subscribe(conn, sub_params);
err = bt_gatt_subscribe(conn, sub_params);
if (err != 0) {
LOG_DBG("Failed to subscribe (err %d)", err);
discovery_complete(conn, err);
return BT_GATT_ITER_STOP;
}
}
return BT_GATT_ITER_CONTINUE;