All of lore.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+99f6ed51479b86ac4c41@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] hfsplus: fix memory leak in hfsplus_fill_super() error path
Date: Fri, 05 Dec 2025 06:48:51 -0800	[thread overview]
Message-ID: <6932f0d3.a70a0220.243dc6.000b.GAE@google.com> (raw)
In-Reply-To: <69326fcf.a70a0220.d98e3.01e5.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] hfsplus: fix memory leak in hfsplus_fill_super() error path
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

When hfsplus_fill_super() fails, the sbi structure is freed but neither
sb->s_fs_info nor fc->s_fs_info are set to NULL. Since sget_fc() copies
fc->s_fs_info to sb->s_fs_info without clearing fc->s_fs_info, both
pointers reference the same memory. After fill_super frees sbi,
hfsplus_free_fc() may operate on a dangling pointer, causing memory
leak or other issues.

Set both sb->s_fs_info and fc->s_fs_info to NULL after freeing sbi
in the error path to ensure proper cleanup.

Reported-by: syzbot+99f6ed51479b86ac4c41@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=99f6ed51479b86ac4c41
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 fs/hfsplus/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 54e85e25a259..f242b88f6633 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -630,6 +630,8 @@ static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc)
 	unload_nls(sbi->nls);
 	unload_nls(nls);
 	kfree(sbi);
+	sb->s_fs_info = NULL;
+	fc->s_fs_info = NULL;
 	return err;
 }
 
-- 
2.43.0


  parent reply	other threads:[~2025-12-05 14:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-05  5:38 [syzbot] [hfs?] memory leak in hfsplus_init_fs_context syzbot
2025-12-05  6:28 ` Forwarded: [PATCH] hfsplus: fix memory leak in hfsplus_fill_super() error path syzbot
2025-12-05  7:51 ` syzbot
2025-12-05 12:43 ` syzbot
2025-12-05 14:48 ` syzbot [this message]
2025-12-06  0:09 ` [PATCH v1] hfsplus: fix memory leak on mount failure Swaraj Gaikwad
2025-12-05 19:06   ` [syzbot] [hfs?] memory leak in hfsplus_init_fs_context syzbot
2025-12-05 20:02   ` [PATCH v1] hfsplus: fix memory leak on mount failure Viacheslav Dubeyko
2025-12-06  9:25   ` [syzbot ci] " syzbot ci

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=6932f0d3.a70a0220.243dc6.000b.GAE@google.com \
    --to=syzbot+99f6ed51479b86ac4c41@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.