mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 22:54:01 +00:00
jbd2: fix potential buffer head reference count leak
commit e0d5fc7a6d
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: stable@kernel.org
Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20220914100812.1414768-2-yebin10@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
aa972fe0f2
commit
68ed9c76b2
1 changed files with 7 additions and 1 deletions
|
@ -928,8 +928,14 @@ int jbd2_fc_wait_bufs(journal_t *journal, int num_blks)
|
|||
wait_on_buffer(bh);
|
||||
put_bh(bh);
|
||||
journal->j_fc_wbuf[i] = NULL;
|
||||
if (unlikely(!buffer_uptodate(bh)))
|
||||
/*
|
||||
* Update j_fc_off so jbd2_fc_release_bufs can release remain
|
||||
* buffer head.
|
||||
*/
|
||||
if (unlikely(!buffer_uptodate(bh))) {
|
||||
journal->j_fc_off = i;
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue