Forwarded: [PATCH] hfsplus: fix memory leak in hfsplus_fill_super() error path

syzbot posted 1 patch 2 weeks ago
There is a newer version of this series
fs/hfsplus/super.c | 1 +
1 file changed, 1 insertion(+)
Forwarded: [PATCH] hfsplus: fix memory leak in hfsplus_fill_super() error path
Posted by syzbot 2 weeks ago
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
sb->s_fs_info is not set to NULL, leaving a dangling pointer.
This can lead to memory leak as reported by syzbot.

Set sb->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 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 54e85e25a259..eb1b262be45e 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -630,6 +630,7 @@ 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;
 	return err;
 }
 
-- 
2.43.0