From 15baadf72cedc2a09ea792c1fc59451502b55da2 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Sat, 16 Feb 2019 11:47:28 -0800 Subject: xfs: fix xfs_buf magic number endian checks Create a separate magic16 check function so that we don't run afoul of static checkers. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_buf.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'fs/xfs/xfs_buf.c') diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 52a382b8cbce..548344e25128 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -2213,7 +2213,7 @@ void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref) bool xfs_verify_magic( struct xfs_buf *bp, - uint32_t dmagic) + __be32 dmagic) { struct xfs_mount *mp = bp->b_target->bt_mount; int idx; @@ -2223,3 +2223,21 @@ xfs_verify_magic( return false; return dmagic == bp->b_ops->magic[idx]; } +/* + * Verify an on-disk magic value against the magic value specified in the + * verifier structure. The verifier magic is in disk byte order so the caller is + * expected to pass the value directly from disk. + */ +bool +xfs_verify_magic16( + struct xfs_buf *bp, + __be16 dmagic) +{ + struct xfs_mount *mp = bp->b_target->bt_mount; + int idx; + + idx = xfs_sb_version_hascrc(&mp->m_sb); + if (unlikely(WARN_ON(!bp->b_ops || !bp->b_ops->magic16[idx]))) + return false; + return dmagic == bp->b_ops->magic16[idx]; +} -- cgit v1.2.3