Skip to content

Commit 3cab377

Browse files
committed
BLE: Fix index access to attcCb.onDeck in Cordio.
The connection starts at 1, not 0. The entry in the array should be connId - 1
1 parent 542b725 commit 3cab377

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ static void attcConnCback(attCcb_t *pCcb, dmEvt_t *pDmEvt)
591591
}
592592

593593
/* free any req on deck */
594-
if (attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE)
594+
if (attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE)
595595
{
596-
attcReqClear(pCcb->connId, &attcCb.onDeck[pCcb->connId], status);
596+
attcReqClear(pCcb->connId, &attcCb.onDeck[pCcb->connId - 1], status);
597597
}
598598

599599
for (i = 0; i < ATT_BEARER_MAX; i++)
@@ -672,7 +672,7 @@ void attcMsgCback(attcApiMsg_t *pMsg)
672672
/* verify no API request already waiting on deck, in progress, or no pending write command
673673
already for this handle */
674674
if (((pCcb->slot == ATT_BEARER_SLOT_ID) &&
675-
(attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE)) ||
675+
(attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE)) ||
676676
(pCcb->outReq.hdr.event > ATTC_MSG_API_MTU) ||
677677
((pMsg->hdr.event == ATTC_MSG_API_WRITE_CMD) &&
678678
attcPendWriteCmd(pCcb, pMsg->handle)))
@@ -686,7 +686,7 @@ void attcMsgCback(attcApiMsg_t *pMsg)
686686
if ((pCcb->slot == ATT_BEARER_SLOT_ID) && (pCcb->outReq.hdr.event == ATTC_MSG_API_MTU))
687687
{
688688
/* put request "on deck" for processing later */
689-
attcCb.onDeck[pCcb->connId] = *pMsg;
689+
attcCb.onDeck[pCcb->connId - 1] = *pMsg;
690690
}
691691
/* otherwise ready to send; set up request */
692692
else
@@ -706,9 +706,9 @@ void attcMsgCback(attcApiMsg_t *pMsg)
706706
}
707707
/* else free any req on deck */
708708
else if ((pCcb->slot == ATT_BEARER_SLOT_ID) &
709-
(attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE))
709+
(attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE))
710710
{
711-
attcReqClear(pCcb->connId, &attcCb.onDeck[pCcb->connId], ATT_ERR_CANCELLED);
711+
attcReqClear(pCcb->connId, &attcCb.onDeck[pCcb->connId - 1], ATT_ERR_CANCELLED);
712712
}
713713
}
714714
/* else if timeout */

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_proc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,13 @@ void attcProcRsp(attcCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
410410
}
411411
/* else if api is on deck */
412412
else if ((pCcb->slot == ATT_BEARER_SLOT_ID) &&
413-
(attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE))
413+
(attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE))
414414
{
415415
/* set up and send request */
416-
attcSetupReq(pCcb, &attcCb.onDeck[pCcb->connId]);
416+
attcSetupReq(pCcb, &attcCb.onDeck[pCcb->connId - 1]);
417417

418418
/* clear on deck */
419-
attcCb.onDeck[pCcb->connId].hdr.event = ATTC_MSG_API_NONE;
419+
attcCb.onDeck[pCcb->connId - 1].hdr.event = ATTC_MSG_API_NONE;
420420
}
421421
}
422422
}

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/attc_sign.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static void attcSignMsgCback(attcCcb_t *pCcb, attcSignMsg_t *pMsg)
178178
/* verify no API request already waiting on deck or in progress,
179179
* and no signed write already in progress
180180
*/
181-
if ((attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE) ||
181+
if ((attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE) ||
182182
(pCcb->outReq.hdr.event > ATTC_MSG_API_MTU) ||
183183
(attcSignCbByConnId((dmConnId_t) pMsg->hdr.param) != NULL))
184184
{
@@ -238,7 +238,7 @@ static void attcSignMsgCback(attcCcb_t *pCcb, attcSignMsg_t *pMsg)
238238
pCcb->pMainCcb->sccb[ATT_BEARER_SLOT_ID].control & ATT_CCB_STATUS_FLOW_DISABLED)
239239
{
240240
/* put request "on deck" for processing later */
241-
attcCb.onDeck[pCcb->connId] = pCb->msg;
241+
attcCb.onDeck[pCcb->connId - 1] = pCb->msg;
242242
}
243243
/* otherwise ready to send */
244244
else

0 commit comments

Comments
 (0)