Skip to content

Commit 5d8170b

Browse files
Thalleyjhedberg
authored andcommitted
Bluetooth: BAP: Add conn check assert in bt_bap_iso_bind_ep
Adds assert for bt_bap_iso_bind_ep to ensure that endpoints from different connection don't share a CIS (a bt_bap_iso). Signed-off-by: Emil Gydesen <[email protected]>
1 parent 1dc98dd commit 5d8170b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

subsys/bluetooth/audio/bap_iso.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ static bool is_unicast_client_ep(struct bt_bap_ep *ep)
241241

242242
void bt_bap_iso_bind_ep(struct bt_bap_iso *iso, struct bt_bap_ep *ep)
243243
{
244+
const struct bt_bap_ep *paired_ep;
244245
struct bt_bap_iso_dir *iso_dir;
245246

246247
__ASSERT_NO_MSG(ep != NULL);
@@ -256,6 +257,15 @@ void bt_bap_iso_bind_ep(struct bt_bap_iso *iso, struct bt_bap_ep *ep)
256257
iso_dir->ep = ep;
257258

258259
ep->iso = bt_bap_iso_ref(iso);
260+
261+
paired_ep = bt_bap_iso_get_paired_ep(ep);
262+
if (paired_ep != NULL && paired_ep->stream != NULL && paired_ep->stream->conn != NULL &&
263+
ep->stream != NULL && ep->stream->conn != NULL) {
264+
__ASSERT(paired_ep->stream->conn == ep->stream->conn,
265+
"Cannot bind ep %p with conn %p to iso %p with paired_ep %p with "
266+
"different conn %p",
267+
ep, ep->stream->conn, iso, paired_ep, paired_ep->stream->conn);
268+
}
259269
}
260270

261271
void bt_bap_iso_unbind_ep(struct bt_bap_iso *iso, struct bt_bap_ep *ep)

0 commit comments

Comments
 (0)