lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251203045048.2463502-1-vivek.balachandhar@gmail.com>
Date: Wed,  3 Dec 2025 04:50:48 +0000
From: Vivek BalachandharTN <vivek.balachandhar@...il.com>
To: jack@...e.com
Cc: linux-ext4@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	vivek.balachandhar@...il.com
Subject: [PATCH] ext2: factor out ext2_fill_super() teardown path

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@...il.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ