STM32F4 platform fix: UART may access free()ed memory.
When closing a UART the code which removes the UART from the linked list contained a school-boy error, where the list entry was free'd and then, on the very next line, it was used.  This is now fixed.
@@ -498,11 +498,11 @@ static bool removeUart(uPortUartData_t *pUartData)
// NULL the entries in the two tables
gpUart[pList->uart] = NULL;
gpDmaUart[pList->pConstData->dmaEngine][pList->pConstData->dmaStream] = NULL;
- // Free memory and set the new head pointer if it's the head
- free(pList);
+ // Set the new head pointer if it's the head and free memory
if (pList == gpUartDataHead) {
gpUartDataHead = pList->pNext;
}
+ free(pList);
}
return found;
