diff options
author | Chao Yu <chao2.yu@samsung.com> | 2015-12-14 18:06:59 +0800 |
---|---|---|
committer | Greg Wallace <greg@gregtwallace.com> | 2016-01-19 22:02:20 -0500 |
commit | 729ecdfdde9259bff68ca8d4fddb3e1d705af941 (patch) | |
tree | fe64d73ce73039012221a8c5cb697a11ac56f00e | |
parent | fd4f8d311aab8d923e31b196ec31106a988d9ea5 (diff) | |
download | android_external_f2fs-tools-729ecdfdde9259bff68ca8d4fddb3e1d705af941.tar.gz android_external_f2fs-tools-729ecdfdde9259bff68ca8d4fddb3e1d705af941.tar.bz2 android_external_f2fs-tools-729ecdfdde9259bff68ca8d4fddb3e1d705af941.zip |
mkfs.f2fs: fix to calculate left space of checkpoint page correctly
We reserved one segment for NAT region at least, so when formatting
fs, calculated maximum size of left space in CP page should be:
CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1 - 64 (size of
reserved NAT bitmap).
Fix the incorrect calculated size to avoid potential overflow bug here.
Change-Id: Ieecd6399a2a519496f9e37c687e99047a7233bf4
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | mkfs/f2fs_format.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index c4b17de..a2f33f9 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -220,7 +220,7 @@ static int f2fs_prepare_super_block(void) * When sit is too large, we should expand cp area. It requires more pages for cp. */ if (max_sit_bitmap_size > - (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 65)) { + (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1 - 64)) { max_nat_bitmap_size = CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1; set_sb(cp_payload, F2FS_BLK_ALIGN(max_sit_bitmap_size)); } else { |