aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunlei He <heyunlei@huawei.com>2017-04-26 15:56:52 +0800
committerMoyster <oysterized@gmail.com>2017-05-21 18:43:52 +0200
commitce598b7834070c25b07e9b3f38f6b05af7985a39 (patch)
tree151a00fd8505c1acf66d6da674bc0127f00ae338
parent3faf20b45d631d42f67d41cbcebaea6a0beb1843 (diff)
f2fs: fix a mount fail for wrong next_scan_nid
-write_checkpoint -do_checkpoint -next_free_nid <--- something wrong with next free nid -f2fs_fill_super -build_node_manager -build_free_nids -get_current_nat_page -__get_meta_page <--- attempt to access beyond end of device Signed-off-by: Yunlei He <heyunlei@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/node.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 9c4c73580..e9f54b38b 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1975,6 +1975,9 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
int i = 0;
nid_t nid = nm_i->next_scan_nid;
+ if (unlikely(nid >= nm_i->max_nid))
+ nid = 0;
+
/* Enough entries */
if (nm_i->nid_cnt[FREE_NID_LIST] >= NAT_ENTRY_PER_BLOCK)
return;