Skip to content

Commit eb640af

Browse files
Kemeng Shitytso
authored andcommitted
ext4: add missing brelse() for bh2 in ext4_dx_add_entry()
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 <[email protected]> Reviewed-by: Ojaswin Mujoo <[email protected]> Reviewed-by: Zhang Yi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent fd3b3d7 commit eb640af

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

fs/ext4/namei.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,8 +2583,10 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
25832583
BUFFER_TRACE(frame->bh, "get_write_access");
25842584
err = ext4_journal_get_write_access(handle, sb, frame->bh,
25852585
EXT4_JTR_NONE);
2586-
if (err)
2586+
if (err) {
2587+
brelse(bh2);
25872588
goto journal_error;
2589+
}
25882590
if (!add_level) {
25892591
unsigned icount1 = icount/2, icount2 = icount - icount1;
25902592
unsigned hash2 = dx_get_hash(entries + icount1);
@@ -2595,8 +2597,10 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
25952597
err = ext4_journal_get_write_access(handle, sb,
25962598
(frame - 1)->bh,
25972599
EXT4_JTR_NONE);
2598-
if (err)
2600+
if (err) {
2601+
brelse(bh2);
25992602
goto journal_error;
2603+
}
26002604

26012605
memcpy((char *) entries2, (char *) (entries + icount1),
26022606
icount2 * sizeof(struct dx_entry));
@@ -2615,8 +2619,10 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
26152619
dxtrace(dx_show_index("node",
26162620
((struct dx_node *) bh2->b_data)->entries));
26172621
err = ext4_handle_dirty_dx_node(handle, dir, bh2);
2618-
if (err)
2622+
if (err) {
2623+
brelse(bh2);
26192624
goto journal_error;
2625+
}
26202626
brelse (bh2);
26212627
err = ext4_handle_dirty_dx_node(handle, dir,
26222628
(frame - 1)->bh);
@@ -2641,8 +2647,10 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
26412647
"Creating %d level index...\n",
26422648
dxroot->info.indirect_levels));
26432649
err = ext4_handle_dirty_dx_node(handle, dir, frame->bh);
2644-
if (err)
2650+
if (err) {
2651+
brelse(bh2);
26452652
goto journal_error;
2653+
}
26462654
err = ext4_handle_dirty_dx_node(handle, dir, bh2);
26472655
brelse(bh2);
26482656
restart = 1;

0 commit comments

Comments
 (0)