Skip to content

Commit 5af8b0a

Browse files
Unbear-HzRbb666
authored andcommitted
[fix][dfs] 修复elmfat挂载失败时的内存泄漏
1 parent 66d3070 commit 5af8b0a

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
156156
/* open the root directory to test whether the fatfs is valid */
157157
result = f_opendir(dir, drive);
158158
if (result != FR_OK)
159+
{
160+
rt_free(dir);
159161
goto __err;
162+
}
160163

161164
/* mount succeed! */
162165
fs->data = fat;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ static int dfs_elm_mount(struct dfs_mnt *mnt, unsigned long rwflag, const void *
192192
/* open the root directory to test whether the fatfs is valid */
193193
result = f_opendir(dir, drive);
194194
if (result != FR_OK)
195+
{
196+
rt_free(dir);
195197
goto __err;
198+
}
196199

197200
/* mount succeed! */
198201
mnt->data = fat;

0 commit comments

Comments
 (0)