[PATCH] xfs: fix misplaced unlikely() parenthesis in xfs_iformat_btree
From: jianyungao89
Date: Tue Nov 03 2026 - 10:19:19 EST
From: Jianyun Gao <jianyungao89@xxxxxxxxx>
The two corruption checks (level == 0 || level > XFS_BM_MAXLEVELS) were
added to xfs_iformat_btree, but the closing parenthesis of unlikely() was
left after the previous condition, leaving the new level checks outside
the unlikely() annotation. Although the boolean result is unaffected
(all conditions are OR'd), the misplaced paren loses the unlikely() hint
for the level checks and indicates the code was not written as intended.
Move the closing parenthesis to the end of the condition list and
update the comment to describe the level check.
Fixes: b3bf607d5852 ("xfs: check for obviously bad level values in the bmbt root")
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Jianyun Gao <jianyungao89@xxxxxxxxx>
---
fs/xfs/libxfs/xfs_inode_fork.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 486fe7ab8b61..48e1c83329ed 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -195,15 +195,16 @@ xfs_iformat_btree(
* blow out if -- fork has less extents than can fit in
* fork (fork shouldn't be a btree format), root btree
* block has more records than can fit into the fork,
- * or the number of extents is greater than the number of
- * blocks.
+ * the number of extents is greater than the number of
+ * blocks, or the btree level is zero or exceeds the
+ * maximum allowed depth.
*/
if (unlikely(ifp->if_nextents <= XFS_IFORK_MAXEXT(ip, whichfork) ||
nrecs == 0 ||
xfs_bmdr_space_calc(nrecs) >
XFS_DFORK_SIZE(dip, mp, whichfork) ||
- ifp->if_nextents > ip->i_nblocks) ||
- level == 0 || level > XFS_BM_MAXLEVELS(mp, whichfork)) {
+ ifp->if_nextents > ip->i_nblocks ||
+ level == 0 || level > XFS_BM_MAXLEVELS(mp, whichfork))) {
xfs_warn(mp, "corrupt inode %llu (btree).",
(unsigned long long)I_INO(ip));
xfs_inode_verifier_error(ip, -EFSCORRUPTED,
--
2.34.1