From: Darrick J. Wong Date: Sun, 3 Jun 2018 23:10:14 +0000 (-0700) Subject: xfs: xfs_alloc_get_rec should return EFSCORRUPTED for obvious bnobt corruption X-Git-Tag: v4.19~795^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a37f7b127ed3dcfab3edc105482891711c1966b3;p=platform%2Fkernel%2Flinux-rpi.git 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 Reviewed-by: Dave Chinner --- diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index dc9dd38..0214a77 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; }