Other Parts Discussed in Thread: CC2640
Hey Friends,
In debugging an Persistent App model OAD on Chip project based on the Basic BLE project, I am wondering if the default code in the 7_40 version of the SDK has an unintended issue:
The code in question is in the bStatus_t OADService_setParameter(oadServiceChar_e srvChar, uint8 len, void *value) function in [oad_service.c] and it appears that the memory allocated for the notification structure
attHandleValueNoti_t notification;
using this line of code:
notification.pValue = GATT_bm_alloc(activeOadCxnHandle, ATT_HANDLE_VALUE_NOTI, len, NULL);
if you examine the error paths in the function there are two paths where this allocated memory (in my case during a BLK SIZE REQUEST from the app) can fail to be returned to the heap.
One is here that might result in a leak:
pAttr = GATTServApp_FindAttr(oadAttrTbl, GATT_NUM_ATTRS(oadAttrTbl), oadCharVals+srvChar);
if(pAttr == NULL)
{
// If we cannot find the attribute, report an error
return (ATT_ERR_ATTR_NOT_FOUND);
}
The other is here, where the wrong pointer is used in the free function:
status = GATT_Notification(activeOadCxnHandle, ¬ification, FALSE);
if (status != SUCCESS)
{
// The stack will free the memory for us if the
// the notification is successful, otherwise we have
// to free the memory manually
GATT_bm_free((gattMsg_t *)¬ification, ATT_HANDLE_VALUE_NOTI);
}
In the later case, the call to GATT_bm_free() attempts to pass the address of the local that is created on the stack which the free command most likely avoids action on (and this perhaps results in another leak).
Question: Am I missing something here? Does the local working copy of this source file need to be modified to correct for these two error paths?
Thanks in advance.
PATH C:\ti\simplelink_lowpower_f3_sdk_7_40_00_64\source\ti\bleapp\services\oad\oad_service.c