Skip to content

Commit cc102aa

Browse files
Kemeng Shitytso
authored andcommitted
jbd2: avoid memleak in jbd2_journal_write_metadata_buffer
The new_bh is from alloc_buffer_head, we should call free_buffer_head to free it in error case. Signed-off-by: Kemeng Shi <[email protected]> Reviewed-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 8dc9c3d commit cc102aa

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/jbd2/journal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
399399
tmp = jbd2_alloc(bh_in->b_size, GFP_NOFS);
400400
if (!tmp) {
401401
brelse(new_bh);
402+
free_buffer_head(new_bh);
402403
return -ENOMEM;
403404
}
404405
spin_lock(&jh_in->b_state_lock);

0 commit comments

Comments
 (0)