From: Artem Martynenko <amartynenko140@gmail.com>
To: stable@vger.kernel.org
Cc: slava@dubeyko.com, glaubitz@physik.fu-berlin.de,
frank.li@vivo.com, linux-fsdevel@vger.kernel.org
Subject: [PATCH 6.18.y] hfsplus: avoid double unload_nls() on mount failure
Date: Wed, 30 Sep 2026 13:31:10 +0300 [thread overview]
Message-ID: <46cb6054-6c05-4869-b4b3-d45eba082253@gmail.com> (raw)
From: Shardul Bankar <shardulsb08@gmail.com>
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/20251201222843.82310-3-mehdi.benhadjkhelifa@gmail.com/
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20260203043806.GF3183987@ZenIV/
Signed-off-by: Shardul Bankar <shardul.b@mpiricsoftware.com>
Link: https://lore.kernel.org/r/20260204170440.1337261-1-shardul.b@mpiricsoftware.com
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Artem Martynenko <amartynenko140@gmail.com>
---
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/9AD67E49-86E9-4508-BBC0-26919C72FB6A@gmail.com
fs/hfsplus/super.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index d031c77fb..0d619945d 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -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;
}
--
2.55.0
reply other threads:[~2026-09-30 10:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46cb6054-6c05-4869-b4b3-d45eba082253@gmail.com \
--to=amartynenko140@gmail.com \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=slava@dubeyko.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox