提交 a4d661dc 编写于 作者: P prife

fix memory leak in dfs_elm.c and umount fatfs when mount fatfs fails (this bug...

fix memory leak in dfs_elm.c and umount fatfs when mount fatfs fails (this bug leads to mkfs failure in linux)
上级 05544d12
......@@ -123,7 +123,12 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
rt_snprintf(drive, sizeof(drive), "%d:/", index);
dir = (DIR *)rt_malloc(sizeof(DIR));
if (dir == RT_NULL)
{
f_mount((BYTE)index, RT_NULL);
disk[index] = RT_NULL;
rt_free(fat);
return -DFS_STATUS_ENOMEM;
}
/* open the root directory to test whether the fatfs is valid */
result = f_opendir(dir, drive);
......@@ -137,6 +142,7 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
}
__err:
f_mount((BYTE)index, RT_NULL);
disk[index] = RT_NULL;
rt_free(fat);
return elm_result_to_dfs(result);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册