diff options
| author | prife <[email protected]> | 2013-01-22 23:47:32 +0800 |
|---|---|---|
| committer | prife <[email protected]> | 2013-01-22 23:47:32 +0800 |
| commit | a4d661dcf182f40ceaca8b15a7d08d0259302044 (patch) | |
| tree | 4e48a3bbf11cf17762def4c26939989456fb6954 /components | |
| parent | 05544d12c97477786c795be514b81cb3c64d327f (diff) | |
fix memory leak in dfs_elm.c and umount fatfs when mount fatfs fails (this bug leads to mkfs failure in linux)
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/filesystems/elmfat/dfs_elm.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index c9fdfb9051..0b85b54810 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -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); |
