mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix: esp_vfs_fat_sdcard_format workbuf memory leak
This commit is contained in:
parent
bcf1645e44
commit
6250af8ed1
@ -462,17 +462,20 @@ esp_err_t esp_vfs_fat_sdcard_format(const char *base_path, sdmmc_card_t *card)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
//unmount
|
||||
char drv[3] = {(char)('0' + pdrv), ':', 0};
|
||||
FRESULT res = f_mount(0, drv, 0);
|
||||
if (res != FR_OK) {
|
||||
ESP_LOGE(TAG, "f_mount unmount failed (%d)", res);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
const size_t workbuf_size = 4096;
|
||||
void *workbuf = ff_memalloc(workbuf_size);
|
||||
if (workbuf == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
//unmount
|
||||
char drv[3] = {(char)('0' + pdrv), ':', 0};
|
||||
FRESULT res = f_mount(0, drv, 0);
|
||||
ESP_RETURN_ON_FALSE(res != FR_INVALID_DRIVE, ESP_FAIL, TAG, "f_mount unmount failed (%d) - the logical drive number is invalid", res);
|
||||
|
||||
//format
|
||||
uint32_t id = FF_VOLUMES;
|
||||
bool found = s_get_context_id_by_card(card, &id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user