summaryrefslogtreecommitdiff
path: root/fs/jbd2
diff options
context:
space:
mode:
authorKemeng Shi <shikemeng@huaweicloud.com>2024-05-14 19:24:30 +0800
committerTheodore Ts'o <tytso@mit.edu>2024-06-27 10:20:26 -0400
commitcc102aa24638b90e04364d64e4f58a1fa91a1976 (patch)
tree3f787c15c602814a962f9f78db2dc3ab48cc21a7 /fs/jbd2
parent8dc9c3da79c84b13fdb135e2fb0a149a8175bffe (diff)
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 <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>
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 03c4b9214f56..5ad255ffb289 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);