Skip to content

Commit e7385c8

Browse files
Ye Bingregkh
Ye Bin
authored andcommitted
jbd2: fix potential buffer head reference count leak
commit e0d5fc7 upstream. As in 'jbd2_fc_wait_bufs' if buffer isn't uptodate, will return -EIO without update 'journal->j_fc_off'. But 'jbd2_fc_release_bufs' will release buffer head from ‘j_fc_off - 1’ if 'bh' is NULL will terminal release which will lead to buffer head buffer head reference count leak. To solve above issue, update 'journal->j_fc_off' before return -EIO. Cc: [email protected] Signed-off-by: Ye Bin <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d87fe29 commit e7385c8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/jbd2/journal.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -926,8 +926,14 @@ int jbd2_fc_wait_bufs(journal_t *journal, int num_blks)
926926
wait_on_buffer(bh);
927927
put_bh(bh);
928928
journal->j_fc_wbuf[i] = NULL;
929-
if (unlikely(!buffer_uptodate(bh)))
929+
/*
930+
* Update j_fc_off so jbd2_fc_release_bufs can release remain
931+
* buffer head.
932+
*/
933+
if (unlikely(!buffer_uptodate(bh))) {
934+
journal->j_fc_off = i;
930935
return -EIO;
936+
}
931937
}
932938

933939
return 0;

0 commit comments

Comments
 (0)