From: Vivek BalachandharTN <vivek.balachandhar@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: jack@suse.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ext2: factor out ext2_fill_super() teardown path
Date: Wed, 3 Dec 2025 11:08:10 -0500 [thread overview]
Message-ID: <cc17bad2-ef56-40bc-9fae-073c1065a57b@gmail.com> (raw)
In-Reply-To: <herlaqmrxfzbh2yqumcquf4ex7qxz5sk47uswmwucdg3pmryez@bvyyavacx5rq>
thanks for the review. You are right — the helper has only one call site
and bh is uninitialized on some failed_sbi paths. I will drop this patch
and look for a more meaningful cleanup in ext2.
Vivek
On 2025-12-03 5:40 a.m., Jan Kara wrote:
> On Wed 03-12-25 04:50:48, Vivek BalachandharTN wrote:
>> 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>
> This is pointless - no point in factoring out helper when it has a single
> call site. Also your patch is broken in several ways (both in correctness
> and style). Please be more thoughtful when submitting patches.
>
> Honza
>
>> +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
>>
next prev parent reply other threads:[~2025-12-03 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 4:50 Vivek BalachandharTN
2025-12-03 10:40 ` Jan Kara
2025-12-03 16:08 ` Vivek BalachandharTN [this message]
2025-12-03 19:19 ` kernel test robot
2025-12-05 9:10 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc17bad2-ef56-40bc-9fae-073c1065a57b@gmail.com \
--to=vivek.balachandhar@gmail.com \
--cc=jack@suse.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®