Skip to content

Commit 126fb0c

Browse files
Mehdibenhadjkhelifadubeyko
authored andcommitted
hfsplus: ensure sb->s_fs_info is always cleaned up
When hfsplus was converted to the new mount api a bug was introduced by changing the allocation pattern of sb->s_fs_info. If setup_bdev_super() fails after a new superblock has been allocated by sget_fc(), but before hfsplus_fill_super() takes ownership of the filesystem-specific s_fs_info data it was leaked. Fix this by freeing sb->s_fs_info in hfsplus_kill_super(). Cc: stable@vger.kernel.org Fixes: 432f7c7 ("hfsplus: convert hfsplus to use the new mount api") Reported-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Tested-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com> Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com> Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com> Link: https://lore.kernel.org/r/20251201222843.82310-3-mehdi.benhadjkhelifa@gmail.com Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
1 parent 05ce49a commit 126fb0c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

fs/hfsplus/super.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ static void hfsplus_put_super(struct super_block *sb)
344344
hfs_btree_close(sbi->ext_tree);
345345
kfree(sbi->s_vhdr_buf);
346346
kfree(sbi->s_backup_vhdr_buf);
347-
call_rcu(&sbi->rcu, delayed_free);
348-
349347
hfs_dbg("finished\n");
350348
}
351349

@@ -650,7 +648,6 @@ static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc)
650648
out_unload_nls:
651649
unload_nls(sbi->nls);
652650
unload_nls(nls);
653-
kfree(sbi);
654651
return err;
655652
}
656653

@@ -709,10 +706,18 @@ static int hfsplus_init_fs_context(struct fs_context *fc)
709706
return 0;
710707
}
711708

709+
static void hfsplus_kill_super(struct super_block *sb)
710+
{
711+
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
712+
713+
kill_block_super(sb);
714+
call_rcu(&sbi->rcu, delayed_free);
715+
}
716+
712717
static struct file_system_type hfsplus_fs_type = {
713718
.owner = THIS_MODULE,
714719
.name = "hfsplus",
715-
.kill_sb = kill_block_super,
720+
.kill_sb = hfsplus_kill_super,
716721
.fs_flags = FS_REQUIRES_DEV,
717722
.init_fs_context = hfsplus_init_fs_context,
718723
};

0 commit comments

Comments
 (0)