u-boot/fs/ubifs
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
..
budget.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
debug.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
debug.h mtd: ubi, ubifs debug: Use pr_debug instead of pr_crit 2019-04-09 07:46:42 +02:00
gc.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
io.c ubifs: do not decide upon uninitialized variable 2021-01-20 14:01:45 -05:00
Kconfig Convert CONFIG_UBIFS_SILENCE_MSG to Kconfig 2018-03-24 06:37:10 +01:00
key.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
log.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
lprops.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
lpt_commit.c crc16: Rename fs/ubifs/crc16.h to include/linux/crc16.h 2022-04-21 14:32:40 -04:00
lpt.c crc16: Rename fs/ubifs/crc16.h to include/linux/crc16.h 2022-04-21 14:32:40 -04:00
Makefile crc16: Move standard CRC-16 implementation from ubifs to lib 2022-04-21 14:32:40 -04:00
master.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
misc.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
orphan.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
recovery.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
replay.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
sb.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
scan.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
super.c ubifs: Fix reference count leak in ubifsumount 2022-07-08 09:05:47 -04:00
tnc_misc.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
tnc.c ubifs: Fix journal replay wrt. xattr nodes 2022-04-11 15:03:28 -04:00
ubifs-media.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ubifs.c ubifs: Fix lockup/crash when reading files 2022-06-03 10:23:22 -04:00
ubifs.h WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00