Skip to content

Commit 1453562

Browse files
committed
[components][dfs][dfs_elm]:fix risk of dangling pointer, unmount the temp driver then free the temp FATFS in dfs_elm_mkfs.
1 parent 0fd8976 commit 1453562

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ int dfs_elm_mkfs(rt_device_t dev_id, const char *fs_name)
280280
/* check flag status, we need clear the temp driver stored in disk[] */
281281
if (flag == FSM_STATUS_USE_TEMP_DRIVER)
282282
{
283-
rt_free(fat);
284283
f_mount(RT_NULL, logic_nbr, (BYTE)index);
284+
rt_free(fat);
285285
disk[index] = RT_NULL;
286286
/* close device */
287287
rt_device_close(dev_id);

components/dfs/dfs_v2/filesystems/elmfat/dfs_elm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ int dfs_elm_mkfs(rt_device_t dev_id, const char *fs_name)
319319
/* check flag status, we need clear the temp driver stored in disk[] */
320320
if (flag == FSM_STATUS_USE_TEMP_DRIVER)
321321
{
322-
rt_free(fat);
323322
f_mount(RT_NULL, logic_nbr, (BYTE)index);
323+
rt_free(fat);
324324
disk[index] = RT_NULL;
325325
/* close device */
326326
rt_device_close(dev_id);

0 commit comments

Comments
 (0)