From: Simon Glass <simon.glass@canonical.com> U-Boot does not track allocated inodes, causing memory leaks when remounting filesystems. Add s_inodes list to super_block and i_sb_list to inode structures to track all allocated inodes, allowing proper eviction on unmount. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 6 ++++++ fs/ext4l/support.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 37a4abb537f..78d44faa0db 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -682,6 +682,9 @@ struct super_block { const struct export_operations *s_export_op; const struct xattr_handler * const *s_xattr; struct dentry *d_sb; /* Parent dentry - stub */ + + /* U-Boot: list of all inodes, for freeing on unmount */ + struct list_head s_inodes; }; /* Block device read-only check - stub */ @@ -859,6 +862,9 @@ struct inode { struct rw_semaphore i_rwsem; /* inode lock */ const char *i_link; /* Symlink target for fast symlinks */ unsigned short i_write_hint; /* Write life time hint */ + + /* U-Boot: linkage into super_block s_inodes list */ + struct list_head i_sb_list; }; /* Inode time accessors */ diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 1fc0bc0aa21..7f2bea4ca06 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -126,6 +126,10 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino) inode->i_mapping = &inode->i_data; inode->i_data.host = inode; INIT_LIST_HEAD(&ei->i_es_list); + INIT_LIST_HEAD(&inode->i_sb_list); + + /* Add to superblock's inode list for eviction on unmount */ + list_add(&inode->i_sb_list, &sb->s_inodes); return inode; } @@ -154,6 +158,10 @@ struct inode *new_inode(struct super_block *sb) inode->i_mapping = &inode->i_data; inode->i_data.host = inode; INIT_LIST_HEAD(&ei->i_es_list); + INIT_LIST_HEAD(&inode->i_sb_list); + + /* Add to superblock's inode list for eviction on unmount */ + list_add(&inode->i_sb_list, &sb->s_inodes); return inode; } -- 2.43.0