mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
gfs2: move brelse() after buffer head accesses
The brelse() call happens before all buffer head accesses are complete. While the reference counting prevents a real use-after-free in practice, this pattern is error-prone for future maintenance. Move the brelse() call to the end of the function to make the intent clearer and eliminate potential static analysis warnings. Suggested-by: Andreas Gruenbacher <agruenba@redhat.com> Suggested-by: Andrew Price <anprice@redhat.com> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
parent
26cb3a444d
commit
59932d7f7e
|
|
@ -1038,7 +1038,6 @@ void gfs2_remove_from_journal(struct buffer_head *bh, int meta)
|
|||
set_bit(TR_TOUCHED, &tr->tr_flags);
|
||||
}
|
||||
was_pinned = 1;
|
||||
brelse(bh);
|
||||
}
|
||||
if (bd) {
|
||||
if (bd->bd_tr) {
|
||||
|
|
@ -1056,6 +1055,8 @@ void gfs2_remove_from_journal(struct buffer_head *bh, int meta)
|
|||
}
|
||||
clear_buffer_dirty(bh);
|
||||
clear_buffer_uptodate(bh);
|
||||
if (was_pinned)
|
||||
brelse(bh);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user