Bluetooth: has: Fix missing preset lookup call

Fixes null-pointer dereference.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
Mariusz Skamra 2022-06-27 13:09:29 +02:00 committed by Carles Cufí
commit 8537e28f66

View file

@ -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) +