Skip to content

Commit 53f5ac0

Browse files
sjancPavelVPV
authored andcommitted
[nrf fromtree] Bluetooth: Host: Fix crash on bt_disable() with limited advertising
When limited advertising is enabled there is pending deleyable work for timing it out. If in such case struct bt_le_ext_adv is cleared by memset system will crash on next tick. Fix this by ensuring work is cancelled before clearing struct bt_le_ext_adv. Using bt_le_ext_adv_foreach() ensures that this will be correctly handled with and without extended advertising enabled. Signed-off-by: Szymon Janc <[email protected]> (cherry picked from commit 973934c) Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent 15d1f70 commit 53f5ac0

File tree

1 file changed

+8
-4
lines changed
  • subsys/bluetooth/host

1 file changed

+8
-4
lines changed

subsys/bluetooth/host/adv.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "hci_core.h"
3535
#include "id.h"
3636
#include "scan.h"
37+
#include "adv.h"
3738

3839
#define LOG_LEVEL CONFIG_BT_HCI_CORE_LOG_LEVEL
3940
LOG_MODULE_REGISTER(bt_adv);
@@ -266,12 +267,15 @@ void bt_le_ext_adv_foreach(void (*func)(struct bt_le_ext_adv *adv, void *data),
266267
#endif /* defined(CONFIG_BT_EXT_ADV) */
267268
}
268269

269-
void bt_adv_reset_adv_pool(void)
270+
static void clear_ext_adv_instance(struct bt_le_ext_adv *adv, void *data)
270271
{
271-
#if defined(CONFIG_BT_EXT_ADV)
272-
(void)memset(&adv_pool, 0, sizeof(adv_pool));
273-
#endif /* defined(CONFIG_BT_EXT_ADV) */
272+
bt_le_lim_adv_cancel_timeout(adv);
273+
memset(adv, 0, sizeof(*adv));
274+
}
274275

276+
void bt_adv_reset_adv_pool(void)
277+
{
278+
bt_le_ext_adv_foreach(clear_ext_adv_instance, NULL);
275279
(void)memset(&bt_dev.adv, 0, sizeof(bt_dev.adv));
276280
}
277281

0 commit comments

Comments
 (0)