Skip to content

Commit 27d1050

Browse files
authored
Merge pull request #13785 from pan-/ble-fix-prep-write-queue-access
BLE: Fix access to attcCb.onDeck and attsCb.prepWriteQueue access
2 parents 5d60e65 + 3cab377 commit 27d1050

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void attsClearPrepWrites(attsCcb_t *pCcb)
366366
{
367367
void *pBuf;
368368

369-
while ((pBuf = WsfQueueDeq(&attsCb.prepWriteQueue[pCcb->connId])) != NULL)
369+
while ((pBuf = WsfQueueDeq(&attsCb.prepWriteQueue[pCcb->connId - 1])) != NULL)
370370
{
371371
WsfBufFree(pBuf);
372372
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void attsProcPrepWriteReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
265265
err = ATT_ERR_LENGTH;
266266
}
267267
/* verify prepare write queue limit not reached */
268-
else if (WsfQueueCount(&attsCb.prepWriteQueue[pCcb->connId]) >= pAttCfg->numPrepWrites)
268+
else if (WsfQueueCount(&attsCb.prepWriteQueue[pCcb->connId - 1]) >= pAttCfg->numPrepWrites)
269269
{
270270
err = ATT_ERR_QUEUE_FULL;
271271
}
@@ -288,7 +288,7 @@ void attsProcPrepWriteReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
288288
pPrep->handle = handle;
289289
pPrep->offset = offset;
290290
memcpy(pPrep->packet, pPacket, writeLen);
291-
WsfQueueEnq(&attsCb.prepWriteQueue[pCcb->connId], pPrep);
291+
WsfQueueEnq(&attsCb.prepWriteQueue[pCcb->connId - 1], pPrep);
292292

293293
/* allocate response buffer */
294294
if ((pBuf = attMsgAlloc(L2C_PAYLOAD_START + ATT_PREP_WRITE_RSP_LEN + writeLen)) != NULL)
@@ -342,7 +342,7 @@ void attsProcExecWriteReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
342342
else if (*pPacket == ATT_EXEC_WRITE_ALL)
343343
{
344344
/* iterate over prepare write queue and verify offset and length */
345-
for (pPrep = attsCb.prepWriteQueue[pCcb->connId].pHead; pPrep != NULL; pPrep = pPrep->pNext)
345+
for (pPrep = attsCb.prepWriteQueue[pCcb->connId - 1].pHead; pPrep != NULL; pPrep = pPrep->pNext)
346346
{
347347
/* find attribute */
348348
if ((pAttr = attsFindByHandle(pPrep->handle, &pGroup)) != NULL)
@@ -371,7 +371,7 @@ void attsProcExecWriteReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
371371
if (err == ATT_SUCCESS)
372372
{
373373
/* for each buffer */
374-
while ((pPrep = WsfQueueDeq(&attsCb.prepWriteQueue[pCcb->connId])) != NULL)
374+
while ((pPrep = WsfQueueDeq(&attsCb.prepWriteQueue[pCcb->connId - 1])) != NULL)
375375
{
376376
/* write buffer */
377377
if ((err = attsExecPrepWrite(pCcb, pPrep)) != ATT_SUCCESS)

0 commit comments

Comments
 (0)