Skip to content

Commit ecdfbea

Browse files
committed
fix:[dfsv1][elm]Fixed a memory leak in dfs_elm_close
1 parent 9e31279 commit ecdfbea

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

components/dfs/Kconfig

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,29 @@ endif
152152
depends on RT_DFS_ELM_REENTRANT
153153

154154
config RT_DFS_ELM_USE_EXFAT
155-
bool "Enable RT_DFS_ELM_USE_EXFAT"
155+
bool "Enable exFAT filesystem support"
156156
default n
157157
depends on RT_DFS_ELM_USE_LFN >= 1
158+
help
159+
exFAT (Extended File Allocation Table) is a file system
160+
designed for large-capacity storage devices.
161+
162+
Key features and recommendations:
163+
- Target scenarios: Primarily used for storage media requiring
164+
support for very large files (>4GB) or large partitions
165+
(>32GB), such as high-capacity SD cards or USB drives.
166+
167+
- Resource cost: Enabling exFAT support will significantly
168+
increase the code size (ROM footprint) of the file system.
169+
170+
- Recommendation:
171+
For small-capacity storage devices (e.g., SPI Flash or
172+
eMMC under 32GB), the standard FAT16 or FAT32 file
173+
systems are perfectly adequate. It is strongly recommended
174+
to keep this option disabled unless you absolutely need to
175+
handle large-capacity storage, in order to conserve
176+
valuable code space.
177+
158178
endmenu
159179
endif
160180

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* 2017-02-13 Hichard Update Fatfs version to 0.12b, support exFAT.
1616
* 2017-04-11 Bernard fix the st_blksize issue.
1717
* 2017-05-26 Urey fix f_mount error when mount more fats
18+
* 2025-10-29 wdfk-prog Fixed a memory leak in dfs_elm_close
1819
*/
1920

2021
#include <rtthread.h>
@@ -468,10 +469,7 @@ int dfs_elm_close(struct dfs_file *file)
468469
FRESULT result;
469470

470471
RT_ASSERT(file->vnode->ref_count > 0);
471-
if (file->vnode->ref_count > 1)
472-
{
473-
return 0;
474-
}
472+
RT_ASSERT(file->data != RT_NULL);
475473
result = FR_OK;
476474
if (file->vnode->type == FT_DIRECTORY)
477475
{

0 commit comments

Comments
 (0)