Skip to content

Commit 0d04f03

Browse files
author
Jaakko Korhonen
committed
Added missing mutex to DataFlash for thread safety.
1 parent 7614055 commit 0d04f03

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ int DataFlashBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
354354
result = BD_ERROR_OK;
355355
}
356356

357+
_mutex.unlock();
357358
return result;
358359
}
359360

@@ -363,6 +364,7 @@ int DataFlashBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t
363364
DEBUG_PRINTF("program: %p %" PRIX64 " %" PRIX64 "\r\n", buffer, addr, size);
364365

365366
if (!_is_initialized) {
367+
_mutex.unlock();
366368
return BD_ERROR_DEVICE_ERROR;
367369
}
368370

@@ -421,6 +423,7 @@ int DataFlashBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t
421423
_write_enable(false);
422424
}
423425

426+
_mutex.unlock();
424427
return result;
425428
}
426429

@@ -430,6 +433,7 @@ int DataFlashBlockDevice::erase(bd_addr_t addr, bd_size_t size)
430433
DEBUG_PRINTF("erase: %" PRIX64 " %" PRIX64 "\r\n", addr, size);
431434

432435
if (!_is_initialized) {
436+
_mutex.unlock();
433437
return BD_ERROR_DEVICE_ERROR;
434438
}
435439

@@ -476,6 +480,7 @@ int DataFlashBlockDevice::erase(bd_addr_t addr, bd_size_t size)
476480
_write_enable(false);
477481
}
478482

483+
_mutex.unlock();
479484
return result;
480485
}
481486

0 commit comments

Comments
 (0)