Skip to contentSkip to conversation

hfsplus: avoid double unload_nls() on mount failure

PATCH New Artem Martynenko 1 participant 1 message Sep 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hfsplus: avoid double unload_nls() on mount failure

From: Shardul Bankar <[email protected]>

commit ebebb04baefdace1e0dc17f7779e5549063ca592 upstream.

The recent commit "hfsplus: ensure sb->s_fs_info is always cleaned up"
[1] introduced a custom ->kill_sb() handler (hfsplus_kill_super) that cleans up the s_fs_info structure (including the NLS table) on superblock destruction.

However, the error handling path in hfsplus_fill_super() still calls unload_nls() before returning an error. Since the VFS layer calls ->kill_sb() when fill_super fails, this results in unload_nls() being called twice for the same sbi->nls pointer: once in hfsplus_fill_super() and again in hfsplus_kill_super() (via delayed_free).

Remove the explicit unload_nls() call from the error path in hfsplus_fill_super() to rely solely on the cleanup in ->kill_sb().

[1] https://lore.kernel.org/r/[email protected]/

---
Tested on 6.18.54 in QEMU: "modprobe nls_utf8; mount -t hfsplus" on a
blank image fails as expected. Without the patch nls_utf8 refcnt goes
to -1 afterwards, with the patch it stays at 0.
Discussion: https://lore.kernel.org/linux-fsdevel/[email protected]

 fs/hfsplus/super.c | 1 -
 1 file changed, 1 deletion(-)
fs/hfsplus/super.c +0 -1
index d031c77fb..0d619945d 100644
@@ -652,7 +652,6 @@ static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc)
 	kfree(sbi->s_vhdr_buf);
 	kfree(sbi->s_backup_vhdr_buf);
 out_unload_nls:
-	unload_nls(sbi->nls);
 	unload_nls(nls);
 	return err;
 }
Signature · 1 line
2.55.0