Skip to content

Commit 11508b2

Browse files
Kemeng Shimehmetb0
authored andcommitted
jbd2: avoid memleak in jbd2_journal_write_metadata_buffer
BugLink: https://bugs.launchpad.net/bugs/2083656 [ Upstream commit cc102aa24638b90e04364d64e4f58a1fa91a1976 ] 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 <shikemeng@huaweicloud.com> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20240514112438.1269037-2-shikemeng@huaweicloud.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent 17227cf commit 11508b2

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)