Skip to content

Commit

Permalink
ext4: add missing brelse() for bh2 in ext4_dx_add_entry()
Browse files Browse the repository at this point in the history
Add missing brelse() for bh2 in ext4_dx_add_entry().

Fixes: ac27a0e ("[PATCH] ext4: initial copy of files from ext3")
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20250123162050.2114499-2-shikemeng@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  • Loading branch information
Kemeng Shi authored and Theodore Ts'o committed Mar 17, 2025
1 parent fd3b3d7 commit eb640af
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions fs/ext4/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2583,8 +2583,10 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
BUFFER_TRACE(frame->bh, "get_write_access");
err = ext4_journal_get_write_access(handle, sb, frame->bh,
EXT4_JTR_NONE);
if (err)
if (err) {
brelse(bh2);
goto journal_error;
}
if (!add_level) {
unsigned icount1 = icount/2, icount2 = icount - icount1;
unsigned hash2 = dx_get_hash(entries + icount1);
Expand All @@ -2595,8 +2597,10 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
err = ext4_journal_get_write_access(handle, sb,
(frame - 1)->bh,
EXT4_JTR_NONE);
if (err)
if (err) {
brelse(bh2);
goto journal_error;
}

memcpy((char *) entries2, (char *) (entries + icount1),
icount2 * sizeof(struct dx_entry));
Expand All @@ -2615,8 +2619,10 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
dxtrace(dx_show_index("node",
((struct dx_node *) bh2->b_data)->entries));
err = ext4_handle_dirty_dx_node(handle, dir, bh2);
if (err)
if (err) {
brelse(bh2);
goto journal_error;
}
brelse (bh2);
err = ext4_handle_dirty_dx_node(handle, dir,
(frame - 1)->bh);
Expand All @@ -2641,8 +2647,10 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
"Creating %d level index...\n",
dxroot->info.indirect_levels));
err = ext4_handle_dirty_dx_node(handle, dir, frame->bh);
if (err)
if (err) {
brelse(bh2);
goto journal_error;
}
err = ext4_handle_dirty_dx_node(handle, dir, bh2);
brelse(bh2);
restart = 1;
Expand Down

0 comments on commit eb640af

Please sign in to comment.