From: Andreas Gruenbacher Date: Tue, 4 Dec 2018 14:06:27 +0000 (+0100) Subject: gfs2: Fix loop in gfs2_rbm_find X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b62cd8c96191f4b83ba0593c63ecf692096bb6e4;p=users%2Fwilly%2Flinux.git gfs2: Fix loop in gfs2_rbm_find In gfs2_rbm_find, fix the resource group wrap-around logic that commit e579ed4f44 broke. Without this fix, gfs2_rbm_find can end up in an infinite loop in the worst case. Fixes: e579ed4f44 ("GFS2: Introduce rbm field bii") Cc: stable@vger.kernel.org # v3.13+ Signed-off-by: Andreas Gruenbacher Signed-off-by: Bob Peterson --- diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index b08a530433ad..8d7916570362 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1780,9 +1780,9 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext, goto next_iter; } if (ret == -E2BIG) { + n += rbm->bii - initial_bii; rbm->bii = 0; rbm->offset = 0; - n += (rbm->bii - initial_bii); goto res_covered_end_of_rgrp; } return ret;