mirror of
https://github.com/torvalds/linux.git
synced 2026-09-27 11:02:03 +02:00
Bluetooth: hci_conn: fix CIS hold ownership on reuse
Commit69997d50ec("Bluetooth: ISO: handle bound CIS cleanup via hci_conn") made hci_bind_cis() and hci_connect_cis() return a connection with one hold for the ISO layer. hci_bind_cis() currently takes that hold only after configuring a CIS, so its BT_CONNECTED and matching BT_BOUND paths return a bare lookup result. Its configuration failure path can likewise call hci_conn_drop() before taking a hold. Take the hold before any state-dependent return or configuration error so every successful return follows the documented ownership contract and every error drop is balanced. hci_connect_cis() also assumes hci_conn_link() always takes a new CIS hold before dropping the one returned by hci_bind_cis(). However, the helper returns an existing link without taking another hold. In that case, preserve the CIS hold for the caller and drop the redundant LE hold because the existing link already owns its parent hold. Returning early also avoids changing an existing CIS back to BT_CONNECT. Fixes:69997d50ec("Bluetooth: ISO: handle bound CIS cleanup via hci_conn") Cc: stable@vger.kernel.org Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
71af682ba4
commit
e06d549fcd
|
|
@ -2079,6 +2079,8 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
|
|||
cis->conn_timeout = timeout;
|
||||
}
|
||||
|
||||
hci_conn_hold(cis);
|
||||
|
||||
if (cis->state == BT_CONNECTED)
|
||||
return cis;
|
||||
|
||||
|
|
@ -2120,7 +2122,6 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
|
|||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
hci_conn_hold(cis);
|
||||
cis->state = BT_BOUND;
|
||||
|
||||
return cis;
|
||||
|
|
@ -2497,6 +2498,12 @@ struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
|
|||
return cis;
|
||||
}
|
||||
|
||||
/* The existing link already owns the hold on its parent. */
|
||||
if (cis->link) {
|
||||
hci_conn_drop(le);
|
||||
return cis;
|
||||
}
|
||||
|
||||
link = hci_conn_link(le, cis);
|
||||
hci_conn_drop(cis);
|
||||
if (!link) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user