[hal] Fix segfault in various HAL functions (#4891)

This commit is contained in:
Dustin Spicuzza
2023-01-02 02:19:04 -05:00
committed by GitHub
parent b0c6724eed
commit 25db20e49d
8 changed files with 25 additions and 1 deletions

View File

@@ -85,6 +85,9 @@ HAL_CANHandle HAL_InitializeCAN(HAL_CANManufacturer manufacturer,
void HAL_CleanCAN(HAL_CANHandle handle) {
auto data = canHandles->Free(handle);
if (data == nullptr) {
return;
}
std::scoped_lock lock(data->mapMutex);

View File

@@ -710,6 +710,9 @@ void HAL_StopDMA(HAL_DMAHandle handle, int32_t* status) {
void* HAL_GetDMADirectPointer(HAL_DMAHandle handle) {
auto dma = dmaHandles->Get(handle);
if (dma == nullptr) {
return nullptr;
}
return dma.get();
}