summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong2018-06-04 01:10:14 +0200
committerDarrick J. Wong2018-06-04 23:45:30 +0200
commita37f7b127ed3dcfab3edc105482891711c1966b3 (patch)
tree054adcbb4fc9396a8587fc2b64475fada77bfccf /fs
parentxfs: remove redundant ASSERT on insufficient bestfree length in _leaf_addname (diff)
downloadkernel-qcow2-linux-a37f7b127ed3dcfab3edc105482891711c1966b3.tar.gz
kernel-qcow2-linux-a37f7b127ed3dcfab3edc105482891711c1966b3.tar.xz
kernel-qcow2-linux-a37f7b127ed3dcfab3edc105482891711c1966b3.zip
xfs: xfs_alloc_get_rec should return EFSCORRUPTED for obvious bnobt corruption
Return -EFSCORRUPTED when the bnobt/cntbt return obviously corrupt values, rather than letting them bounce around in the internal code. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index dc9dd3805d97..0214a77808d0 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -231,10 +231,14 @@ xfs_alloc_get_rec(
int error;
error = xfs_btree_get_rec(cur, &rec, stat);
- if (!error && *stat == 1) {
- *bno = be32_to_cpu(rec->alloc.ar_startblock);
- *len = be32_to_cpu(rec->alloc.ar_blockcount);
- }
+ if (error || !(*stat))
+ return error;
+ if (rec->alloc.ar_blockcount == 0)
+ return -EFSCORRUPTED;
+
+ *bno = be32_to_cpu(rec->alloc.ar_startblock);
+ *len = be32_to_cpu(rec->alloc.ar_blockcount);
+
return error;
}