Skip to content
/ linux Public

Commit 0bcfebb

Browse files
MehdibenhadjkhelifaSasha Levin
authored andcommitted
hfsplus: ensure sb->s_fs_info is always cleaned up
[ Upstream commit 126fb0c ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 428093c commit 0bcfebb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fs/hfsplus/super.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,6 @@ static void hfsplus_put_super(struct super_block *sb)
350350
hfs_btree_close(sbi->ext_tree);
351351
kfree(sbi->s_vhdr_buf);
352352
kfree(sbi->s_backup_vhdr_buf);
353-
call_rcu(&sbi->rcu, delayed_free);
354-
355353
hfs_dbg("finished\n");
356354
}
357355

@@ -656,7 +654,6 @@ static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc)
656654
out_unload_nls:
657655
unload_nls(sbi->nls);
658656
unload_nls(nls);
659-
kfree(sbi);
660657
return err;
661658
}
662659

@@ -715,10 +712,18 @@ static int hfsplus_init_fs_context(struct fs_context *fc)
715712
return 0;
716713
}
717714

715+
static void hfsplus_kill_super(struct super_block *sb)
716+
{
717+
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
718+
719+
kill_block_super(sb);
720+
call_rcu(&sbi->rcu, delayed_free);
721+
}
722+
718723
static struct file_system_type hfsplus_fs_type = {
719724
.owner = THIS_MODULE,
720725
.name = "hfsplus",
721-
.kill_sb = kill_block_super,
726+
.kill_sb = hfsplus_kill_super,
722727
.fs_flags = FS_REQUIRES_DEV,
723728
.init_fs_context = hfsplus_init_fs_context,
724729
};

0 commit comments

Comments
 (0)