Skip to contentSkip to conversation

exfat: fix memory leak in exfat_fill_super

PATCH In review YangWen 2 participants 2 messages Nov 23, 2025 – Nov 24, 2025

Subsystems (2)
lore
Share & tools
lore

YangWen

author
#0 lore raw

PATCH 1/1 exfat: fix memory leak in exfat_fill_super

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")
---
 fs/exfat/super.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/exfat/super.c +5 -0
index 74d451f732c7..db28a426206c 100644
@@ -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;
 }
 
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 3 lines · YangWen

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.

Quoted 3 lines
Fixes 719c1e1829166 ("exfat: add super block operations")