Skip to content

Commit

Permalink
Bluetooth: hci_conn: avoid checking uninitialized CIG/CIS ids
Browse files Browse the repository at this point in the history
The CIS/CIG ids of ISO connections are defined only when the connection
is unicast.

Fix the lookup functions to check for unicast first. Ensure CIG/CIS
IDs have valid value also in state BT_OPEN.

Signed-off-by: Pauli Virtanen <pav@iki.fi>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Pauli Virtanen authored and Luiz Augusto von Dentz committed Aug 11, 2023
1 parent 66dee21 commit b5793de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
rcu_read_lock();

list_for_each_entry_rcu(c, &h->list, list) {
if (c->type != ISO_LINK)
if (c->type != ISO_LINK || !bacmp(&c->dst, BDADDR_ANY))
continue;

/* Match CIG ID if set */
Expand Down Expand Up @@ -1251,7 +1251,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_cig(struct hci_dev *hdev,
rcu_read_lock();

list_for_each_entry_rcu(c, &h->list, list) {
if (c->type != ISO_LINK)
if (c->type != ISO_LINK || !bacmp(&c->dst, BDADDR_ANY))
continue;

if (handle == c->iso_qos.ucast.cig) {
Expand Down
2 changes: 2 additions & 0 deletions net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,8 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
return ERR_PTR(-ENOMEM);
cis->cleanup = cis_cleanup;
cis->dst_type = dst_type;
cis->iso_qos.ucast.cig = BT_ISO_QOS_CIG_UNSET;
cis->iso_qos.ucast.cis = BT_ISO_QOS_CIS_UNSET;
}

if (cis->state == BT_CONNECTED)
Expand Down

0 comments on commit b5793de

Please sign in to comment.