Merge branch 'fix/vfs_fatfs_unregister_path_possible_leak_v6.0' into 'release/v6.0'

Fix esp_vfs_fat_unregister_path possible leak, incorrect check in esp_vfs_register_fs_common and optimize memory usage (v6.0)

See merge request espressif/esp-idf!49638
This commit is contained in:
Jiang Jiang Jian
2026-06-29 15:40:19 +08:00
5 changed files with 30 additions and 31 deletions
+2 -2
View File
@@ -237,7 +237,7 @@ esp_err_t esp_vfs_fat_unregister_path(const char* base_path)
vfs_fat_ctx_t* fat_ctx = s_fat_ctxs[ctx];
esp_err_t err = esp_vfs_unregister(fat_ctx->base_path);
if (err != ESP_OK) {
return err;
ESP_LOGW(TAG, "esp_vfs_unregister failed (0x%x), cleaning up anyway", err); // should not happen, but if it does, we don't want to leak memory and keep the VFS in a broken state
}
_lock_close(&fat_ctx->lock);
@@ -251,7 +251,7 @@ esp_err_t esp_vfs_fat_unregister_path(const char* base_path)
free(fat_ctx->flags);
free(fat_ctx);
s_fat_ctxs[ctx] = NULL;
return ESP_OK;
return err;
}
esp_err_t esp_vfs_fat_info(const char* base_path,