From d8530b790738dd6b9093c39675d720daa9f76853 Mon Sep 17 00:00:00 2001 From: Jaakko Korhonen Date: Tue, 30 Oct 2018 10:22:59 +0200 Subject: [PATCH] Added missing mutex to DataFlash for thread safety. --- .../blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp index 4dc5542c58..635e4fe016 100644 --- a/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp @@ -354,6 +354,7 @@ int DataFlashBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) result = BD_ERROR_OK; } + _mutex.unlock(); return result; } @@ -363,6 +364,7 @@ int DataFlashBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t DEBUG_PRINTF("program: %p %" PRIX64 " %" PRIX64 "\r\n", buffer, addr, size); if (!_is_initialized) { + _mutex.unlock(); return BD_ERROR_DEVICE_ERROR; } @@ -421,6 +423,7 @@ int DataFlashBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t _write_enable(false); } + _mutex.unlock(); return result; } @@ -430,6 +433,7 @@ int DataFlashBlockDevice::erase(bd_addr_t addr, bd_size_t size) DEBUG_PRINTF("erase: %" PRIX64 " %" PRIX64 "\r\n", addr, size); if (!_is_initialized) { + _mutex.unlock(); return BD_ERROR_DEVICE_ERROR; } @@ -476,6 +480,7 @@ int DataFlashBlockDevice::erase(bd_addr_t addr, bd_size_t size) _write_enable(false); } + _mutex.unlock(); return result; }