Skip to content

Commit 03333fe

Browse files
committed
Bluetooth: ISO: Cleanup BIG before stopped callback
Modify the big_disconnect function to do cleanup_big before calling the `stopped` callback. This will allow the ISO channels, as well as the BIG itself, to be reused for other purposes directly in the stopped callback, without having to offload such actions to a separate thread. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 94764d1 commit 03333fe

File tree

1 file changed

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

1 file changed

+5
-8
lines changed

subsys/bluetooth/host/iso.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,6 +2731,11 @@ static void big_disconnect(struct bt_iso_big *big, uint8_t reason)
27312731
bt_iso_chan_disconnected(bis, reason);
27322732
}
27332733

2734+
/* Cleanup the BIG before calling the `stopped` so that the `big` pointer and the ISO
2735+
* channels in the `big` can be reused in the callback
2736+
*/
2737+
cleanup_big(big);
2738+
27342739
if (!sys_slist_is_empty(&iso_big_cbs)) {
27352740
struct bt_iso_big_cb *listener;
27362741

@@ -3147,7 +3152,6 @@ void hci_le_big_complete(struct net_buf *buf)
31473152
big = big_lookup_flag(BT_BIG_PENDING);
31483153
if (big) {
31493154
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3150-
cleanup_big(big);
31513155
}
31523156

31533157
return;
@@ -3165,7 +3169,6 @@ void hci_le_big_complete(struct net_buf *buf)
31653169
big->num_bis);
31663170
}
31673171
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3168-
cleanup_big(big);
31693172
return;
31703173
}
31713174

@@ -3205,7 +3208,6 @@ void hci_le_big_terminate(struct net_buf *buf)
32053208
LOG_DBG("BIG[%u] %p terminated", big->handle, big);
32063209

32073210
big_disconnect(big, evt->reason);
3208-
cleanup_big(big);
32093211
}
32103212
#endif /* CONFIG_BT_ISO_BROADCASTER */
32113213

@@ -3292,7 +3294,6 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
32923294

32933295
if (!err) {
32943296
big_disconnect(big, BT_HCI_ERR_LOCALHOST_TERM_CONN);
3295-
cleanup_big(big);
32963297
}
32973298
} else {
32983299
err = -EINVAL;
@@ -3337,7 +3338,6 @@ void hci_le_big_sync_established(struct net_buf *buf)
33373338
big = big_lookup_flag(BT_BIG_SYNCING);
33383339
if (big) {
33393340
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3340-
cleanup_big(big);
33413341
}
33423342

33433343
return;
@@ -3355,7 +3355,6 @@ void hci_le_big_sync_established(struct net_buf *buf)
33553355
big->num_bis);
33563356
}
33573357
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3358-
cleanup_big(big);
33593358
return;
33603359
}
33613360

@@ -3395,7 +3394,6 @@ void hci_le_big_sync_lost(struct net_buf *buf)
33953394
LOG_DBG("BIG[%u] %p sync lost", big->handle, big);
33963395

33973396
big_disconnect(big, evt->reason);
3398-
cleanup_big(big);
33993397
}
34003398

34013399
static int hci_le_big_create_sync(const struct bt_le_per_adv_sync *sync, struct bt_iso_big *big,
@@ -3587,7 +3585,6 @@ void bt_iso_reset(void)
35873585
struct bt_iso_big *big = &bigs[i];
35883586

35893587
big_disconnect(big, BT_HCI_ERR_UNSPECIFIED);
3590-
cleanup_big(big);
35913588
}
35923589
#endif /* CONFIG_BT_ISO_BROADCAST */
35933590
}

0 commit comments

Comments
 (0)