diff --git a/features/filesystem/bd/MBRBlockDevice.cpp b/features/filesystem/bd/MBRBlockDevice.cpp
index e83e4fbf07..bcea66f69b 100644
--- a/features/filesystem/bd/MBRBlockDevice.cpp
+++ b/features/filesystem/bd/MBRBlockDevice.cpp
@@ -242,6 +242,7 @@ int MBRBlockDevice::init()
 
     // Check that block addresses are valid
     if (!_bd->is_valid_erase(_offset, _size)) {
+        delete[] buffer;
         return BD_ERROR_INVALID_PARTITION;
     }