From fae2beba9d3785dd91bc6f600c69edf9864f1287 Mon Sep 17 00:00:00 2001 From: Morten Priess Date: Mon, 26 Sep 2022 08:52:45 +0200 Subject: [PATCH] Bluetooth: controller: Don't consider CIS connected before established Make sure ll_iso_stream_connected_get returns NULL until CIS is established. Always return DISALLOWED when trying to disconnect a CIS which is not connected. Signed-off-by: Morten Priess --- subsys/bluetooth/controller/ll_sw/ull_conn.c | 5 +++-- subsys/bluetooth/controller/ll_sw/ull_conn_iso.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index cdbe59514bb..a3f1af84897 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -624,12 +624,13 @@ uint8_t ll_terminate_ind_send(uint16_t handle, uint8_t reason) if (IS_CIS_HANDLE(handle)) { #if !defined(CONFIG_BT_LL_SW_LLCP_LEGACY) cis = ll_iso_stream_connected_get(handle); + /* Disallow if CIS is not connected */ if (!cis) { - return BT_HCI_ERR_UNKNOWN_CONN_ID; + return BT_HCI_ERR_CMD_DISALLOWED; } conn = ll_connected_get(cis->lll.acl_handle); - /* Is conn still connected? */ + /* Disallow if ACL has disconnected */ if (!conn) { return BT_HCI_ERR_CMD_DISALLOWED; } diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c b/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c index a532f69ebfb..92ecd5322a5 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c @@ -159,8 +159,10 @@ struct ll_conn_iso_stream *ll_iso_stream_connected_get(uint16_t handle) } cis = ll_conn_iso_stream_get(handle); - if ((cis->group == NULL) || (cis->lll.handle != handle)) { - /* CIS does not belong to a group or has inconsistent handle */ + if ((cis->group == NULL) || (cis->lll.handle != handle) || !cis->established) { + /* CIS does not belong to a group, has inconsistent handle or is + * not yet established. + */ return NULL; }