jbd2: avoid memleak in jbd2_journal_write_metadata_buffer
[ 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>
This commit is contained in:
parent
04fd4f1796
commit
1c047adeaa
@ -399,6 +399,7 @@ repeat:
|
|||||||
tmp = jbd2_alloc(bh_in->b_size, GFP_NOFS);
|
tmp = jbd2_alloc(bh_in->b_size, GFP_NOFS);
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
brelse(new_bh);
|
brelse(new_bh);
|
||||||
|
free_buffer_head(new_bh);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
spin_lock(&jh_in->b_state_lock);
|
spin_lock(&jh_in->b_state_lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user