Skip to content

Commit 2170353

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 767c4d7 commit 2170353

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
@@ -2722,6 +2722,11 @@ static void big_disconnect(struct bt_iso_big *big, uint8_t reason)
27222722
bt_iso_chan_disconnected(bis, reason);
27232723
}
27242724

2725+
/* Cleanup the BIG before calling the `stopped` so that the `big` pointer and the ISO
2726+
* channels in the `big` can be reused in the callback
2727+
*/
2728+
cleanup_big(big);
2729+
27252730
if (!sys_slist_is_empty(&iso_big_cbs)) {
27262731
struct bt_iso_big_cb *listener;
27272732

@@ -3158,7 +3163,6 @@ void hci_le_big_complete(struct net_buf *buf)
31583163
big = big_lookup_flag(BT_BIG_PENDING);
31593164
if (big) {
31603165
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3161-
cleanup_big(big);
31623166
}
31633167

31643168
return;
@@ -3176,7 +3180,6 @@ void hci_le_big_complete(struct net_buf *buf)
31763180
big->num_bis);
31773181
}
31783182
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3179-
cleanup_big(big);
31803183
return;
31813184
}
31823185

@@ -3216,7 +3219,6 @@ void hci_le_big_terminate(struct net_buf *buf)
32163219
LOG_DBG("BIG[%u] %p terminated", big->handle, big);
32173220

32183221
big_disconnect(big, evt->reason);
3219-
cleanup_big(big);
32203222
}
32213223
#endif /* CONFIG_BT_ISO_BROADCASTER */
32223224

@@ -3303,7 +3305,6 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
33033305

33043306
if (!err) {
33053307
big_disconnect(big, BT_HCI_ERR_LOCALHOST_TERM_CONN);
3306-
cleanup_big(big);
33073308
}
33083309
} else {
33093310
err = -EINVAL;
@@ -3352,7 +3353,6 @@ void hci_le_big_sync_established(struct net_buf *buf)
33523353
big = big_lookup_flag(BT_BIG_SYNCING);
33533354
if (big) {
33543355
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3355-
cleanup_big(big);
33563356
}
33573357

33583358
return;
@@ -3370,7 +3370,6 @@ void hci_le_big_sync_established(struct net_buf *buf)
33703370
big->num_bis);
33713371
}
33723372
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3373-
cleanup_big(big);
33743373
return;
33753374
}
33763375

@@ -3410,7 +3409,6 @@ void hci_le_big_sync_lost(struct net_buf *buf)
34103409
LOG_DBG("BIG[%u] %p sync lost", big->handle, big);
34113410

34123411
big_disconnect(big, evt->reason);
3413-
cleanup_big(big);
34143412
}
34153413

34163414
static int hci_le_big_create_sync(const struct bt_le_per_adv_sync *sync, struct bt_iso_big *big,
@@ -3621,7 +3619,6 @@ void bt_iso_reset(void)
36213619
struct bt_iso_big *big = &bigs[i];
36223620

36233621
big_disconnect(big, BT_HCI_ERR_UNSPECIFIED);
3624-
cleanup_big(big);
36253622
}
36263623
#endif /* CONFIG_BT_ISO_BROADCAST */
36273624
}

0 commit comments

Comments
 (0)