fatfs: Fix some memory leak issues by coverity static analyzer.

This commit is contained in:
aditi_lonkar 2021-03-23 11:57:50 +05:30
parent d3fa4c3749
commit 3a40b3b349
2 changed files with 6 additions and 3 deletions

View File

@ -5586,7 +5586,10 @@ FRESULT f_mkfs (
sz_buf = len / ss; /* Size of working buffer (sector) */ sz_buf = len / ss; /* Size of working buffer (sector) */
szb_buf = sz_buf * ss; /* Size of working buffer (byte) */ szb_buf = sz_buf * ss; /* Size of working buffer (byte) */
} }
if (!buf || sz_buf == 0) return FR_NOT_ENOUGH_CORE; if (!buf || sz_buf == 0) {
ff_memfree(buf);
return FR_NOT_ENOUGH_CORE;
}
/* Determine where the volume to be located (b_vol, sz_vol) */ /* Determine where the volume to be located (b_vol, sz_vol) */
if (FF_MULTI_PARTITION && part != 0) { if (FF_MULTI_PARTITION && part != 0) {

View File

@ -630,12 +630,12 @@ static int vfs_fat_link(void* ctx, const char* n1, const char* n2)
} }
fail3: fail3:
f_close(pf2); f_close(pf2);
free(pf2);
fail2: fail2:
f_close(pf1); f_close(pf1);
free(pf1);
fail1: fail1:
free(buf); free(buf);
free(pf2);
free(pf1);
if (res != FR_OK) { if (res != FR_OK) {
ESP_LOGD(TAG, "%s: fresult=%d", __func__, res); ESP_LOGD(TAG, "%s: fresult=%d", __func__, res);
errno = fresult_to_errno(res); errno = fresult_to_errno(res);