Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport v2.7-branch] Bluetooth: Controller: Control procedure error code and compiler re-ordering fixes #74140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions subsys/bluetooth/controller/hci/hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -6319,7 +6319,7 @@ static void le_ltk_request(struct pdu_data *pdu_data, uint16_t handle,
}

static void encrypt_change(uint8_t err, uint16_t handle,
struct net_buf *buf)
struct net_buf *buf, bool encryption_on)
{
struct bt_hci_evt_encrypt_change *ep;

Expand All @@ -6330,9 +6330,9 @@ static void encrypt_change(uint8_t err, uint16_t handle,
hci_evt_create(buf, BT_HCI_EVT_ENCRYPT_CHANGE, sizeof(*ep));
ep = net_buf_add(buf, sizeof(*ep));

ep->status = err;
ep->status = err ? err : (encryption_on ? err : BT_HCI_ERR_UNSPECIFIED);
ep->handle = sys_cpu_to_le16(handle);
ep->encrypt = !err ? 1 : 0;
ep->encrypt = encryption_on ? 1 : 0;
}
#endif /* CONFIG_BT_CTLR_LE_ENC */

Expand Down Expand Up @@ -6457,7 +6457,7 @@ static void encode_data_ctrl(struct node_rx_pdu *node_rx,
break;

case PDU_DATA_LLCTRL_TYPE_START_ENC_RSP:
encrypt_change(0x00, handle, buf);
encrypt_change(0x00, handle, buf, true);
break;
#endif /* CONFIG_BT_CTLR_LE_ENC */

Expand All @@ -6474,7 +6474,7 @@ static void encode_data_ctrl(struct node_rx_pdu *node_rx,
#if defined(CONFIG_BT_CTLR_LE_ENC)
case PDU_DATA_LLCTRL_TYPE_REJECT_IND:
encrypt_change(pdu_data->llctrl.reject_ind.error_code, handle,
buf);
buf, false);
break;
#endif /* CONFIG_BT_CTLR_LE_ENC */

Expand Down
3 changes: 3 additions & 0 deletions subsys/bluetooth/controller/ll_sw/ull.c
Original file line number Diff line number Diff line change
Expand Up @@ -1667,12 +1667,15 @@ int ull_disable(void *lll)
if (!hdr || !ull_ref_get(hdr)) {
return 0;
}
cpu_dmb(); /* Ensure synchronized data access */

k_sem_init(&sem, 0, 1);

hdr->disabled_param = &sem;
hdr->disabled_cb = disabled_cb;

cpu_dmb(); /* Ensure synchronized data access */

/* ULL_HIGH can run after we have call `ull_ref_get` and it can
* decrement the ref count. Hence, handle this race condition by
* ensuring that `disabled_cb` has been set while the ref count is still
Expand Down
Loading