From b0c495791a5892d2088142588437785c41bbea22 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Fri, 6 Sep 2019 12:00:46 +0530 Subject: [PATCH] Bluetooth: controller: split: Fix start encryption in progress check Fix check in start encryption to disallow new encryption setup while there is one already in progress. Relates to commit 120eba45f81b ("Bluetooth: controller: Fix start encryption in progress check"). Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ll_sw/ull_master.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull_master.c b/subsys/bluetooth/controller/ll_sw/ull_master.c index 5a1d5081c12..e18dc49cfdd 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_master.c +++ b/subsys/bluetooth/controller/ll_sw/ull_master.c @@ -344,7 +344,9 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk) return BT_HCI_ERR_UNKNOWN_CONN_ID; } - if (conn->llcp_enc.req != conn->llcp_enc.ack) { + if ((conn->llcp_enc.req != conn->llcp_enc.ack) || + ((conn->llcp_req != conn->llcp_ack) && + (conn->llcp_type == LLCP_ENCRYPTION))) { return BT_HCI_ERR_CMD_DISALLOWED; } @@ -356,7 +358,7 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk) memcpy(&conn->llcp_enc.ltk[0], ltk, sizeof(conn->llcp_enc.ltk)); - if ((conn->lll.enc_rx == 0) && (conn->lll.enc_tx == 0)) { + if (!conn->lll.enc_rx && !conn->lll.enc_tx) { struct pdu_data_llctrl_enc_req *enc_req; pdu_data_tx->ll_id = PDU_DATA_LLID_CTRL; @@ -372,7 +374,7 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk) enc_req->ediv[1] = ediv[1]; bt_rand(enc_req->skdm, sizeof(enc_req->skdm)); bt_rand(enc_req->ivm, sizeof(enc_req->ivm)); - } else if ((conn->lll.enc_rx != 0) && (conn->lll.enc_tx != 0)) { + } else if (conn->lll.enc_rx && conn->lll.enc_tx) { memcpy(&conn->llcp_enc.rand[0], rand, sizeof(conn->llcp_enc.rand));