summaryrefslogtreecommitdiff
path: root/fs/fs.c
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut+renesas@gmail.com>2019-02-06 13:19:29 +0100
committerMarek Vasut <marex@denx.de>2019-02-09 11:08:40 +0100
commite531c6731b697fc524b54697caebf235a4a69e8d (patch)
tree5ebf50f2d2a4615d7aa96e9a84d9e28cce252d3a /fs/fs.c
parent6892550c4aea4e9fcbee3cdb6947ac78085981ae (diff)
fs: ext4: Unmount FS in do_fs_type()
Unlike other generic FS accessors, fs_get_info() does not call fs_close() at the end of it's operation. Thus, using fs_get_info() in do_fs_type() without calling fs_close() causes potential memory leak by creating new filesystem structures on each call of do_fs_type(). The test case to trigger this problem is as follows. It is required to have ext4 filesystem on the first partition of the SDMMC device, since ext4 requires stateful mount and causes memory allocation. => while true ; do mmc rescan ; fstype mmc 1 ; done Eventually, the mounting of ext4 will fail due to malloc failures and the filesystem will not be correctly detected. This patch fixes the problem by adding the missing fs_close(). Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'fs/fs.c')
-rw-r--r--fs/fs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 0e9c2f1062..c5c35ebf5f 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -801,6 +801,8 @@ int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
else
printf("%s\n", info->name);
+ fs_close();
+
return CMD_RET_SUCCESS;
}