fatfs: check allocated workbuf pointer

This commit is contained in:
Ivan Grokhotkov 2018-01-08 16:21:44 +08:00
parent 59859fa53c
commit bf53c8abb1
2 changed files with 9 additions and 1 deletions

View file

@ -113,8 +113,12 @@ esp_err_t esp_vfs_fat_sdmmc_mount(const char* base_path,
goto fail;
}
ESP_LOGW(TAG, "partitioning card");
DWORD plist[] = {100, 0, 0, 0};
workbuf = malloc(workbuf_size);
if (workbuf == NULL) {
err = ESP_ERR_NO_MEM;
goto fail;
}
DWORD plist[] = {100, 0, 0, 0};
res = f_fdisk(s_pdrv, plist, workbuf);
if (res != FR_OK) {
err = ESP_FAIL;

View file

@ -79,6 +79,10 @@ esp_err_t esp_vfs_fat_spiflash_mount(const char* base_path,
goto fail;
}
workbuf = malloc(workbuf_size);
if (workbuf == NULL) {
result = ESP_ERR_NO_MEM;
goto fail;
}
size_t alloc_unit_size = esp_vfs_fat_get_allocation_unit_size(
CONFIG_WL_SECTOR_SIZE,
mount_config->allocation_unit_size);