Skip to content

Commit bf53c8a

Browse files
committed
fatfs: check allocated workbuf pointer
1 parent 59859fa commit bf53c8a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

components/fatfs/src/vfs_fat_sdmmc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ esp_err_t esp_vfs_fat_sdmmc_mount(const char* base_path,
113113
goto fail;
114114
}
115115
ESP_LOGW(TAG, "partitioning card");
116-
DWORD plist[] = {100, 0, 0, 0};
117116
workbuf = malloc(workbuf_size);
117+
if (workbuf == NULL) {
118+
err = ESP_ERR_NO_MEM;
119+
goto fail;
120+
}
121+
DWORD plist[] = {100, 0, 0, 0};
118122
res = f_fdisk(s_pdrv, plist, workbuf);
119123
if (res != FR_OK) {
120124
err = ESP_FAIL;

components/fatfs/src/vfs_fat_spiflash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ esp_err_t esp_vfs_fat_spiflash_mount(const char* base_path,
7979
goto fail;
8080
}
8181
workbuf = malloc(workbuf_size);
82+
if (workbuf == NULL) {
83+
result = ESP_ERR_NO_MEM;
84+
goto fail;
85+
}
8286
size_t alloc_unit_size = esp_vfs_fat_get_allocation_unit_size(
8387
CONFIG_WL_SECTOR_SIZE,
8488
mount_config->allocation_unit_size);

0 commit comments

Comments
 (0)