The error path at the end of ext2_fill_super() open-codes the final teardown of the ext2_sb_info structure and associated resources. Centralize this into a small helper to make the control flow a bit clearer and avoid repeating the same cleanup sequence in multiple labels. Behavior is unchanged. Signed-off-by: Vivek BalachandharTN --- fs/ext2/super.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 121e634c792a..19d4ec95e5a7 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -874,6 +874,19 @@ static void ext2_set_options(struct fs_context *fc, struct ext2_sb_info *sbi) le16_to_cpu(es->s_def_resgid)); } +static void ext2_free_sbi(struct super_block *sb, + struct ext2_sb_info *sbi, + struct buffer_head *bh) +{ + if (bh) + brelse(bh); + + fs_put_dax(sbi->s_daxdev, NULL); + sb->s_fs_info = NULL; + kfree(sbi->s_blockgroup_lock); + kfree(sbi); +} + static int ext2_fill_super(struct super_block *sb, struct fs_context *fc) { struct ext2_fs_context *ctx = fc->fs_private; @@ -1251,12 +1264,8 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc) kvfree(sbi->s_group_desc); kfree(sbi->s_debts); failed_mount: - brelse(bh); failed_sbi: - fs_put_dax(sbi->s_daxdev, NULL); - sb->s_fs_info = NULL; - kfree(sbi->s_blockgroup_lock); - kfree(sbi); + ext2_free_sbi(sb, sbi, bh); return ret; } -- 2.34.1