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:
Hongling Zeng 2026-08-25 09:55:01 +08:00 committed by Andreas Gruenbacher
parent 26cb3a444d
commit 59932d7f7e

View File

@ -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);
}
/**