From: Christoph Hellwig Date: Wed, 11 May 2011 15:04:07 +0000 (+0000) Subject: xfs: do not use unchecked extent indices in xfs_bmapi X-Git-Tag: v3.0-rc1~139^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5690f92199956c0f2a2d9f718b5031e1300a1de1;p=profile%2Fivi%2Fkernel-x86-ivi.git xfs: do not use unchecked extent indices in xfs_bmapi Make sure to only call xfs_iext_get_ext after we've validate the extent index when moving on to the next index in xfs_bmapi. Based on an earlier patch from Lachlan McIlroy. Signed-off-by: Christoph Hellwig Reviewed-by: Lachlan McIlroy Signed-off-by: Alex Elder --- diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 130ec4f..af655c1 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c @@ -4825,12 +4825,13 @@ xfs_bmapi( /* * Else go on to the next record. */ - ep = xfs_iext_get_ext(ifp, ++lastx); prev = got; - if (lastx >= nextents) - eof = 1; - else + if (++lastx < nextents) { + ep = xfs_iext_get_ext(ifp, lastx); xfs_bmbt_get_all(ep, &got); + } else { + eof = 1; + } } *nmap = n; /*