f2fs: fix overflow due to condition check order
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 23 Nov 2016 18:51:17 +0000 (10:51 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 23 Nov 2016 20:10:48 +0000 (12:10 -0800)
commite87f7329bbd6760c2acc4f1eb423362b08851a71
tree6d28cf50361a531e77bc758ab7807d845e25d787
parentded9b5dd205ef04aa095c3b731c635b201191a59
f2fs: fix overflow due to condition check order

In the last ilen case, i was already increased, resulting in accessing out-
of-boundary entry of do_replace and blkaddr.
Fix to check ilen first to exit the loop.

Fixes: 2aa8fbb9693020 ("f2fs: refactor __exchange_data_block for speed up")
Cc: stable@vger.kernel.org # 4.8+
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c