Bluetooth: Audio: HAS: Fix active_preset_work initialization

The security_changed callback may be called before
bt_has_register has been called, thus making the active_preset_work
handler uninitailized, causing an ASSERT when the work is submitted
in the security changed callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2023-01-09 14:49:12 +01:00 committed by Lauren Murphy
commit ea858f26c5

View file

@ -135,7 +135,8 @@ static struct has_preset {
static uint8_t has_preset_num; static uint8_t has_preset_num;
/* Active preset notification work */ /* Active preset notification work */
static struct k_work active_preset_work; static void active_preset_work_process(struct k_work *work);
static K_WORK_DEFINE(active_preset_work, active_preset_work_process);
static void process_control_point_work(struct k_work *work); static void process_control_point_work(struct k_work *work);
@ -1180,10 +1181,6 @@ int bt_has_register(const struct bt_has_register_param *param)
return err; return err;
} }
#if defined(CONFIG_BT_HAS_PRESET_SUPPORT)
k_work_init(&active_preset_work, active_preset_work_process);
#endif /* CONFIG_BT_HAS_PRESET_SUPPORT */
registered = true; registered = true;
return 0; return 0;