diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2018-09-10 18:31:47 +0200 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2018-10-12 14:18:25 +0200 |
commit | f654683dae0d6c4e02eb7126b14f19fd945c3569 (patch) | |
tree | e83f79c4db82d60f9b708e629a259fbdb937c9bf /fs/gfs2/rgrp.c | |
parent | gfs2: getlabel support (diff) | |
download | linux-f654683dae0d6c4e02eb7126b14f19fd945c3569.tar.xz linux-f654683dae0d6c4e02eb7126b14f19fd945c3569.zip |
gfs2: Always check the result of gfs2_rbm_from_block
When gfs2_rbm_from_block fails, the rbm it returns is undefined, so we
always want to make sure gfs2_rbm_from_block has succeeded before
looking at the rbm.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Reviewed-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/rgrp.c')
-rw-r--r-- | fs/gfs2/rgrp.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index b445ae15f87e..7f8b562d1cbe 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -2233,7 +2233,8 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart, return NULL; } - gfs2_rbm_from_block(&rbm, bstart); + if (WARN_ON_ONCE(gfs2_rbm_from_block(&rbm, bstart))) + return NULL; while (blen--) { bi = rbm_bi(&rbm); if (bi != bi_prev) { @@ -2366,7 +2367,10 @@ static void gfs2_set_alloc_start(struct gfs2_rbm *rbm, else goal = rbm->rgd->rd_last_alloc + rbm->rgd->rd_data0; - gfs2_rbm_from_block(rbm, goal); + if (WARN_ON_ONCE(gfs2_rbm_from_block(rbm, goal))) { + rbm->bii = 0; + rbm->offset = 0; + } } /** @@ -2575,7 +2579,8 @@ int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, unsigned int type) rbm.rgd = rgd; error = gfs2_rbm_from_block(&rbm, no_addr); - WARN_ON_ONCE(error != 0); + if (WARN_ON_ONCE(error)) + goto fail; if (gfs2_testbit(&rbm, false) != type) error = -ESTALE; |