From: Yunlei He Date: Wed, 26 Apr 2017 07:56:52 +0000 (+0800) Subject: f2fs: fix a mount fail for wrong next_scan_nid X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e9cdd307704b5a8f685fa3fff4403691fbf64f97;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index b99e318bce58..98351a4a4da3 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1955,6 +1955,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;