Skip to content

Commit 9dadf11

Browse files
cvinayakanangl
authored andcommitted
[nrf fromtree] Bluetooth: Controller: Add explicit LLCP error code check
Add unit tests to cover explicit LLCP error code check and cover the same in the Controller implementation. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]> (cherry picked from commit d6f2bc9) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 4160a17 commit 9dadf11

File tree

2 files changed

+433
-4
lines changed

2 files changed

+433
-4
lines changed

subsys/bluetooth/controller/ll_sw/ull_llcp_enc.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,19 +369,29 @@ static void lp_enc_store_s(struct ll_conn *conn, struct proc_ctx *ctx, struct pd
369369

370370
static inline uint8_t reject_error_code(struct pdu_data *pdu)
371371
{
372+
uint8_t error;
373+
372374
if (pdu->llctrl.opcode == PDU_DATA_LLCTRL_TYPE_REJECT_IND) {
373-
return pdu->llctrl.reject_ind.error_code;
375+
error = pdu->llctrl.reject_ind.error_code;
374376
#if defined(CONFIG_BT_CTLR_EXT_REJ_IND)
375377
} else if (pdu->llctrl.opcode == PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND) {
376-
return pdu->llctrl.reject_ext_ind.error_code;
378+
error = pdu->llctrl.reject_ext_ind.error_code;
377379
#endif /* CONFIG_BT_CTLR_EXT_REJ_IND */
378380
} else {
379381
/* Called with an invalid PDU */
380382
LL_ASSERT(0);
381383

382384
/* Keep compiler happy */
383-
return BT_HCI_ERR_UNSPECIFIED;
385+
error = BT_HCI_ERR_UNSPECIFIED;
386+
}
387+
388+
/* Check expected error code from the peer */
389+
if (error != BT_HCI_ERR_PIN_OR_KEY_MISSING &&
390+
error != BT_HCI_ERR_UNSUPP_REMOTE_FEATURE) {
391+
error = BT_HCI_ERR_UNSPECIFIED;
384392
}
393+
394+
return error;
385395
}
386396

387397
static void lp_enc_st_wait_rx_enc_rsp(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,

0 commit comments

Comments
 (0)