summaryrefslogtreecommitdiff
path: root/fs/jbd2
diff options
context:
space:
mode:
authorKemeng Shi <shikemeng@huaweicloud.com>2024-05-14 19:24:30 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-08-14 13:58:46 +0200
commit6dacca9fbe5298e116a66b126b6409f2c02ba2c4 (patch)
tree0e549f96c261b09b63b1f31a7a0e4f2f7cfd4a2b /fs/jbd2
parente7abdad660edc0051ae9dcd22328e713ed28fd8d (diff)
downloadlinux-6dacca9fbe5298e116a66b126b6409f2c02ba2c4.tar.gz
linux-6dacca9fbe5298e116a66b126b6409f2c02ba2c4.tar.bz2
linux-6dacca9fbe5298e116a66b126b6409f2c02ba2c4.zip
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>
Diffstat (limited to 'fs/jbd2')
-rw-r--r--fs/jbd2/journal.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 0168d2842707..57264eb4d9da 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -399,6 +399,7 @@ repeat:
tmp = jbd2_alloc(bh_in->b_size, GFP_NOFS);
if (!tmp) {
brelse(new_bh);
+ free_buffer_head(new_bh);
return -ENOMEM;
}
spin_lock(&jh_in->b_state_lock);