From ea858f26c53faa36a08d1553c4a4e6b64f43b4b4 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Mon, 9 Jan 2023 14:49:12 +0100 Subject: [PATCH] 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 --- subsys/bluetooth/audio/has.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/subsys/bluetooth/audio/has.c b/subsys/bluetooth/audio/has.c index b909132e39c..39fddb90ff8 100644 --- a/subsys/bluetooth/audio/has.c +++ b/subsys/bluetooth/audio/has.c @@ -135,7 +135,8 @@ static struct has_preset { static uint8_t has_preset_num; /* 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); @@ -1180,10 +1181,6 @@ int bt_has_register(const struct bt_has_register_param *param) 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; return 0;