diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 6d18d2c91add..66ee8fb06ab9 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -281,7 +281,7 @@ static int gfs2_read_sb(struct gfs2_sbd *sdp, int silent) { u32 hash_blocks, ind_blocks, leaf_blocks; u32 tmp_blocks; - unsigned int x; + unsigned int x, index; int error; error = gfs2_read_super(sdp, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift, silent); @@ -329,20 +329,21 @@ static int gfs2_read_sb(struct gfs2_sbd *sdp, int silent) sdp->sd_heightsize[0] = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); sdp->sd_heightsize[1] = sdp->sd_sb.sb_bsize * sdp->sd_diptrs; - for (x = 2;; x++) { + for (x = 2; x <= GFS2_MAX_META_HEIGHT; x++) { u64 space, d; u32 m; - space = sdp->sd_heightsize[x - 1] * sdp->sd_inptrs; + index = x; + space = sdp->sd_heightsize[index - 1] * sdp->sd_inptrs; d = space; m = do_div(d, sdp->sd_inptrs); - if (d != sdp->sd_heightsize[x - 1] || m) + if (d != sdp->sd_heightsize[index - 1] || m) break; - sdp->sd_heightsize[x] = space; + sdp->sd_heightsize[index] = space; } - sdp->sd_max_height = x; - sdp->sd_heightsize[x] = ~0; + sdp->sd_max_height = index; + sdp->sd_heightsize[index] = ~0; gfs2_assert(sdp, sdp->sd_max_height <= GFS2_MAX_META_HEIGHT); sdp->sd_max_dents_per_leaf = (sdp->sd_sb.sb_bsize -