Skip to content

Commit ed01ff4

Browse files
committed
Bluetooth: CAP: Add ep conn check in unicast audio start
Add check in valid_unicast_audio_start_param to verify that the ep connection matches the member_conn. Signed-off-by: Emil Gydesen <[email protected]>
1 parent cd76dde commit ed01ff4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

subsys/bluetooth/audio/cap_initiator.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,9 +1161,11 @@ static bool valid_unicast_audio_start_param(const struct bt_cap_unicast_audio_st
11611161
const union bt_cap_set_member *member = &stream_param->member;
11621162
const struct bt_cap_stream *cap_stream = stream_param->stream;
11631163
const struct bt_audio_codec_cfg *codec_cfg = stream_param->codec_cfg;
1164+
const struct bt_bap_ep *ep = stream_param->ep;
11641165
const struct bt_bap_stream *bap_stream;
11651166
const struct bt_conn *member_conn =
11661167
bt_cap_common_get_member_conn(param->type, member);
1168+
struct bt_conn *ep_conn;
11671169

11681170
if (member == NULL) {
11691171
LOG_DBG("param->members[%zu] is NULL", i);
@@ -1185,11 +1187,26 @@ static bool valid_unicast_audio_start_param(const struct bt_cap_unicast_audio_st
11851187
return false;
11861188
}
11871189

1188-
CHECKIF(stream_param->ep == NULL) {
1190+
if (ep == NULL) {
11891191
LOG_DBG("param->stream_params[%zu].ep is NULL", i);
11901192
return false;
11911193
}
11921194

1195+
ep_conn = bt_bap_ep_get_conn(ep);
1196+
if (ep_conn == NULL) {
1197+
LOG_DBG("param->stream_params[%zu].ep is invalid", i);
1198+
return false;
1199+
}
1200+
if (ep_conn != member_conn) {
1201+
LOG_DBG("param->stream_params[%zu].ep conn %p does not match "
1202+
"param->members[%zu] %p",
1203+
i, ep_conn, i, member_conn);
1204+
bt_conn_unref(ep_conn);
1205+
1206+
return false;
1207+
}
1208+
bt_conn_unref(ep_conn);
1209+
11931210
CHECKIF(member == NULL) {
11941211
LOG_DBG("param->stream_params[%zu].member is NULL", i);
11951212
return false;

0 commit comments

Comments
 (0)