diff --git a/features/filesystem/bd/MBRBlockDevice.cpp b/features/filesystem/bd/MBRBlockDevice.cpp index a8e74fad727..e83e4fbf076 100644 --- a/features/filesystem/bd/MBRBlockDevice.cpp +++ b/features/filesystem/bd/MBRBlockDevice.cpp @@ -241,7 +241,9 @@ int MBRBlockDevice::init() _size = fromle32(table->entries[_part-1].lba_size) * sector; // Check that block addresses are valid - MBED_ASSERT(_bd->is_valid_erase(_offset, _size)); + if (!_bd->is_valid_erase(_offset, _size)) { + return BD_ERROR_INVALID_PARTITION; + } delete[] buffer; return 0;