diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index b99e318bce584b0c4b0adad3114fb1f17ddcdee2..98351a4a4da3f41d00fa3e3256ce741b59e6d715 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;