From 0ff297cf0ef77a4dd01003e707b15e19c6e0cb72 Mon Sep 17 00:00:00 2001 From: Felix Date: Thu, 21 Nov 2024 18:48:48 +0100 Subject: [PATCH] Cordio BLE: Dynamically calculate message length The vendor specific HCI event can contain messages of arbitrary length, thus the length of the message allocation must depend on the length of the event. --- .../cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c index fd708ea2ddd..5d650749a0e 100644 --- a/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c +++ b/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c @@ -2738,6 +2738,7 @@ void hciEvtProcessMsg(uint8_t *pEvt) uint8_t evt; uint8_t subEvt; uint8_t len; + uint8_t extraMsgLen = 0; uint8_t cbackEvt = 0; hciEvt_t *pMsg; uint16_t handle; @@ -2997,6 +2998,7 @@ void hciEvtProcessMsg(uint8_t *pEvt) #endif hciEvtStats.numVendorSpecEvt++; cbackEvt = HCI_VENDOR_SPEC_CBACK_EVT; + extraMsgLen = len; #ifdef WSF_DETOKEN_TRACE if (WsfDetokenProcessHciEvent(len, pEvt)) @@ -3014,7 +3016,7 @@ void hciEvtProcessMsg(uint8_t *pEvt) if (cbackEvt != 0) { /* allocate temp buffer */ - if ((pMsg = WsfBufAlloc(hciEvtCbackLen[cbackEvt])) != NULL) + if ((pMsg = WsfBufAlloc(hciEvtCbackLen[cbackEvt] + extraMsgLen)) != NULL) { /* initialize message header */ pMsg->hdr.param = 0;