Affected function: DSPI_DRV_MasterTransferDataBlocking(...) in ./KSDK/platform/drivers/dspi/dspi_master/src/fsl_dspi_master_driver.c
Leak conditions: utilize DSPI Peripheral Driver in combination with FreeRTOS (not verified for other RTOS implementations)
Leak description: for every call to DSPI_DRV_MasterTransferDataBlocking(...) a new counting semaphore is created using a unconditional function call to OSA_SemaCreate(..). This routes to the FreeRTOS function xSemaphoreCreateCounting(...) which will allocate new memory for the requested Semaphore using the local malloc implementation. The returned new memory address is assigned to the Semaphore Sync Object Pointer in the DSPI State Object (irqSync) without ever freeing the memory of the formerly created Semaphore hereby loosing any reference to the old memory. This will lead to a stack overflow after certain number of calls to the TransferData function depending on the stack size.
Workaround: Check if the Semaphore has been created before calling OSA_SemaCreate(...). Instead loop over the Semaphore with a timeout of 0 trying to acquire it until its count is 0 to put it in the same condition as it would be after initialization.