[PATCH v2] ubifs: Fix reference count leak in ubifsumount

Tom Rini trini at konsulko.com
Fri Jul 8 18:38:26 CEST 2022


On Mon, May 30, 2022 at 11:09:11AM +0200, Pali Rohár wrote:

> 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 at kernel.org>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20220708/a61d01e6/attachment.sig>


More information about the U-Boot mailing list