[PATCH] fs: Do not mntput() the root device parent

Sascha Hauer s.hauer at pengutronix.de
Wed Apr 15 06:08:54 PDT 2026


The vfs rootfs ("/") parent points to itself, so do not call mntput() on
the parent when it's the root device as the reference counter would
become negative.

This doesn't happen in normal configurations as we normally have a ramfs
mounted at / and we leave fs_remove() early in that case. Some xload
configurations have a FAT from SD/eMMC mounted at / though which leads
to a "refcount for mount \"%s\" becomes negative\n" warning.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 fs/fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index f1f69a501f..a562fe0fc6 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -874,7 +874,8 @@ static void fs_remove(struct device *dev)
 	list_for_each_entry_safe(inode, tmp, &sb->s_inodes, i_sb_list)
 		destroy_inode(inode);
 
-	mntput(fsdev->vfsmount.parent);
+	if (&fsdev->vfsmount != fsdev->vfsmount.parent)
+		mntput(fsdev->vfsmount.parent);
 
 	free(fsdev->backingstore);
 }
-- 
2.47.3




More information about the barebox mailing list