mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ext2: factor out ext2_fill_super() teardown path
@ 2025-12-03  4:50 Vivek BalachandharTN
  2025-12-03 10:40 ` Jan Kara
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vivek BalachandharTN @ 2025-12-03  4:50 UTC (permalink / raw)
  To: jack; +Cc: linux-ext4, linux-kernel, vivek.balachandhar

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 <vivek.balachandhar@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-05  9:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-03  4:50 [PATCH] ext2: factor out ext2_fill_super() teardown path Vivek BalachandharTN
2025-12-03 10:40 ` Jan Kara
2025-12-03 16:08   ` Vivek BalachandharTN
2025-12-03 19:19 ` kernel test robot
2025-12-05  9:10 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®