f2fs: fix overflow due to condition check order
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 23 Nov 2016 18:51:17 +0000 (10:51 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Jan 2017 09:40:14 +0000 (10:40 +0100)
commit027611ef345d118310c1334b5d25b27ff95da684
tree54ca384f255b293a0c88402f8b92dab066c95b73
parent1134ef11ffffcfb69834c86f632c0ce0c639524a
f2fs: fix overflow due to condition check order

commit e87f7329bbd6760c2acc4f1eb423362b08851a71 upstream.

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")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/f2fs/file.c