[PATCH] exfat: fix memory leak in exfat_fill_super

YangWen posted 1 patch 1 week, 1 day ago
fs/exfat/super.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] exfat: fix memory leak in exfat_fill_super
Posted by YangWen 1 week, 1 day ago
If exFAT encounters errors during multiple mount operations, 'sbi' and 'nls' will not be released,
which will cause a memory leak.

Fixes: 719c1e1829166 ("exfat: add super block operations")
Signed-off-by: YangWen <anmuxixixi@gmail.com>
---
 fs/exfat/super.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index 74d451f732c7..db28a426206c 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -722,10 +722,15 @@ static int exfat_fill_super(struct super_block *sb, struct fs_context *fc)
 	sb->s_root = NULL;
 
 free_table:
+	exfat_free_upcase_table(sbi);
 	exfat_free_bitmap(sbi);
 	brelse(sbi->boot_bh);
 
 check_nls_io:
+	unload_nls(sbi->nls_io);
+	exfat_free_iocharset(sbi);
+	sb->s_fs_info = NULL;
+	kfree(sbi);
 	return err;
 }
 
-- 
2.43.0
Re: [PATCH] exfat: fix memory leak in exfat_fill_super
Posted by Namjae Jeon 1 week ago
On Sun, Nov 23, 2025 at 9:13 PM YangWen <anmuxixixi@gmail.com> wrote:
>
> If exFAT encounters errors during multiple mount operations, 'sbi' and 'nls' will not be released,
> which will cause a memory leak.
delayed_free() will free them.
Please check it.
Thanks.
>
> Fixes: 719c1e1829166 ("exfat: add super block operations")
> Signed-off-by: YangWen <anmuxixixi@gmail.com>