Home
last modified time | relevance | path

Searched hist:"410 b6a2cf1ab023b4830ed2ce9679af74bc8c4c7" (Results 1 – 1 of 1) sorted by relevance

/rk3399_rockchip-uboot/fs/ubifs/
H A Dsuper.c410b6a2cf1ab023b4830ed2ce9679af74bc8c4c7 Mon May 30 09:09:11 UTC 2022 Pali Rohár <pali@kernel.org> UPSTREAM: 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

Change-Id: I8f5400dbdb98374e3f5a6bce82a5f53e5ecb89bc
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 69ca709d0fb001851f443b0b744c6d65bb6c22c1)