fs: ext4: Unmount FS in do_fs_type()
authorMarek Vasut <marek.vasut+renesas@gmail.com>
Wed, 6 Feb 2019 12:19:29 +0000 (13:19 +0100)
committerVagrant Cascadian <vagrant@debian.org>
Tue, 14 May 2019 02:07:44 +0000 (03:07 +0100)
commit861b61f1c6193e54011c7f5c57756f8770a76937
treea8e462be7d879028b0dd663ed2a565f6d50c9b44
parentc7d2d9df327cd340d6196f40ca4ea03156c82e75
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>
Gbp-Pq: Topic upstream
Gbp-Pq: Name fs-ext4-Unmount-FS-in-do_fs_type.patch
fs/fs.c