diff --git a/subsys/bluetooth/audio/has.c b/subsys/bluetooth/audio/has.c index eb3cb1e6fe7..f1baf24dc77 100644 --- a/subsys/bluetooth/audio/has.c +++ b/subsys/bluetooth/audio/has.c @@ -840,6 +840,11 @@ int bt_has_preset_available(uint8_t index) return -EINVAL; } + preset_foreach(index, index, preset_found, &preset); + if (preset == NULL) { + return -ENOENT; + } + /* toggle property bit if needed */ if (!(preset->properties & BT_HAS_PROP_AVAILABLE)) { NET_BUF_SIMPLE_DEFINE(buf, sizeof(struct bt_has_cp_hdr) + @@ -865,6 +870,11 @@ int bt_has_preset_unavailable(uint8_t index) return -EINVAL; } + preset_foreach(index, index, preset_found, &preset); + if (preset == NULL) { + return -ENOENT; + } + /* toggle property bit if needed */ if (preset->properties & BT_HAS_PROP_AVAILABLE) { NET_BUF_SIMPLE_DEFINE(buf, sizeof(struct bt_has_cp_hdr) +