Skip to content

Commit

Permalink
f2fs: fix overflow due to condition check order
Browse files Browse the repository at this point in the history
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: [email protected] # 4.8+
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Jaegeuk Kim committed Nov 23, 2016
1 parent ded9b5d commit e87f732
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode,
new_size = (dst + i) << PAGE_SHIFT;
if (dst_inode->i_size < new_size)
f2fs_i_size_write(dst_inode, new_size);
} while ((do_replace[i] || blkaddr[i] == NULL_ADDR) && --ilen);
} while (--ilen && (do_replace[i] || blkaddr[i] == NULL_ADDR));

f2fs_put_dnode(&dn);
} else {
Expand Down

0 comments on commit e87f732

Please sign in to comment.