u-boot/fs
Pali Rohár 69ca709d0f ubifs: Fix reference count leak in ubifsumount
Original ubifs code was designed that after ubifs_umount() call it is
required to also call ubi_close_volume() which closes underlying UBI
volume. But U-Boot ubifs modification have not implemented it properly
which caused that ubifsumount command contains resource leak. It can be
observed by calling simple sequence of commands:

  => ubi part mtd2
  ubi0: attaching mtd2
  ...
  => ubifsmount ubi0
  => ubifsumount
  Unmounting UBIFS volume rootfs!
  => ubi detach
  ubi0 error: ubi_detach_mtd_dev: ubi0 reference count 1, destroy anyway
  ubi0: detaching mtd2
  ubi0: mtd2 is detached

Fix this issue by calling ubi_close_volume() and mutex_unlock() in
directly in ubifs_umount() function before freeing U-Boot's global
ubifs_sb. And remove duplicate calls of these two functions in remaining
places. Note that when ubifs_umount() is not called then during error
handling is still needed to call ubi_close_volume() and mutex_unlock.

With this change ubifsumount command does not throw that error anymore:

  => ubi part rootfs
  ubi0: attaching mtd2
  ...
  => ubifsmount ubi0
  => ubifsumount
  Unmounting UBIFS volume rootfs!
  => ubi detach
  ubi0: detaching mtd2
  ubi0: mtd2 is detached

Signed-off-by: Pali Rohár <pali@kernel.org>
2022-07-08 09:05:47 -04:00
..
btrfs btrfs: simplify lookup_data_extent() 2022-06-06 17:47:17 -04:00
cbfs spl: Ensure all SPL symbols in Kconfig have some SPL dependency 2022-07-07 09:29:08 -04:00
cramfs common: Drop flash.h from common header 2020-05-18 14:53:28 -04:00
erofs fs/erofs: add lz4 decompression support 2022-03-15 16:19:29 -04:00
ext4 fs: ext4: Use CRC-16 implementation from linux/crc16.h 2022-04-21 14:32:40 -04:00
fat doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
jffs2 Convert CONFIG_JFFS2_DEV et al to Kconfig 2021-12-27 16:20:19 -05:00
reiserfs common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
sandbox bootstd: sandbox: Add a hostfs bootdev 2022-04-25 10:00:04 -04:00
squashfs Merge branch 'master' into next 2022-06-20 14:40:59 -04:00
ubifs ubifs: Fix reference count leak in ubifsumount 2022-07-08 09:05:47 -04:00
yaffs2 fs: yaffs2: Finish Kconfig migration 2021-11-05 11:23:29 -04:00
zfs common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
fs.c fs: Add a function to set the filesystem type 2022-04-25 10:00:03 -04:00
fs_internal.c fs: convert error and debug messages to log 2020-09-06 21:21:41 +02:00
Kconfig bootstd: sandbox: Add a hostfs bootdev 2022-04-25 10:00:04 -04:00
Makefile fs: Add semihosting filesystem 2022-04-01 15:03:13 -04:00
semihostingfs.c fs: Add semihosting filesystem 2022-04-01 15:03:13 -04:00