aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2018-10-11 13:35:50 -0400
committerBob Peterson <rpeterso@redhat.com>2018-10-12 08:28:39 -0400
commit3548fce1645bafbeb2256caaa3635a21bafd1621 (patch)
tree38fa90bb1d04080382f3530cfd370e9197e49220
parentf654683dae0d6c4e02eb7126b14f19fd945c3569 (diff)
gfs2: Clean up out-of-bounds check in gfs2_rbm_from_block
We already have a function that checks if a block is within a resource group, so use that in gfs2_rbm_from_block as well. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Bob Peterson <rpeterso@redhat.com> Reviewed-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/gfs2/rgrp.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 7f8b562d1cbe..6eb2addcbff5 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -273,15 +273,10 @@ static u32 gfs2_bitfit(const u8 *buf, const unsigned int len,
273 273
274static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block) 274static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block)
275{ 275{
276 u64 rblock = block - rbm->rgd->rd_data0; 276 if (!rgrp_contains_block(rbm->rgd, block))
277
278 if (WARN_ON_ONCE(rblock > UINT_MAX))
279 return -EINVAL;
280 if (block >= rbm->rgd->rd_data0 + rbm->rgd->rd_data)
281 return -E2BIG; 277 return -E2BIG;
282
283 rbm->bii = 0; 278 rbm->bii = 0;
284 rbm->offset = (u32)(rblock); 279 rbm->offset = block - rbm->rgd->rd_data0;
285 /* Check if the block is within the first block */ 280 /* Check if the block is within the first block */
286 if (rbm->offset < rbm_bi(rbm)->bi_blocks) 281 if (rbm->offset < rbm_bi(rbm)->bi_blocks)
287 return 0; 282 return 0;