Skip to content

Commit 52cb2c2

Browse files
author
Kyle Kearney
committed
Avoid stale mutex in QSPIFBlockDevice::read
Update to follow the same `goto exit_point` pattern that is used by the rest of the functions to avoid leaving the mutex locked when errors are detected and require the function to abort.
1 parent 3f20b80 commit 52cb2c2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,26 @@ int QSPIFBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
310310
if (QSPI_STATUS_OK != _qspi_configure_format(_inst_width, _address_width, _address_size, _address_width, // Alt width == address width
311311
_alt_size, _data_width, _dummy_cycles)) {
312312
tr_error("_qspi_configure_format failed");
313-
return QSPIF_BD_ERROR_DEVICE_ERROR;
313+
status = QSPIF_BD_ERROR_DEVICE_ERROR;
314+
goto exit_point;
314315
}
315316

316317
if (QSPI_STATUS_OK != _qspi_send_read_command(_read_instruction, buffer, addr, size)) {
317318
tr_error("Read Command failed");
318-
return QSPIF_BD_ERROR_DEVICE_ERROR;
319+
status = QSPIF_BD_ERROR_DEVICE_ERROR;
320+
goto exit_point;
319321
}
320322

321323
// All commands other than Read use default 1-1-1 Bus mode (Program/Erase are constrained by flash memory performance more than bus performance)
322324
if (QSPI_STATUS_OK != _qspi_configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE, 0, QSPI_CFG_BUS_SINGLE, 0)) {
323325
tr_error("_qspi_configure_format failed");
324-
return QSPIF_BD_ERROR_DEVICE_ERROR;
326+
status = QSPIF_BD_ERROR_DEVICE_ERROR;
327+
goto exit_point;
325328
}
326329

330+
exit_point:
327331
_mutex.unlock();
332+
328333
return status;
329334

330335
}

0 commit comments

Comments
 (0)