Bluetooth: has: Fix missing preset lookup call
Fixes null-pointer dereference.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
diff --git a/subsys/bluetooth/audio/has.c b/subsys/bluetooth/audio/has.c
index eb3cb1e..f1baf24 100644
--- a/subsys/bluetooth/audio/has.c
+++ b/subsys/bluetooth/audio/has.c
@@ -840,6 +840,11 @@
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 @@
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) +