fsck.f2fs: do not access nat etnries in ckpt before initialization

ckpt->entries is initialized by fsck_init(), but we tried to access it during
f2fs_do_mount().

The call sequence is:
 - f2fs_do_mount
  - record_fsync_data
    - traverse_dnodes
     - do_record_fsync_data
      - ADDRS_PER_PAGE
       - get_node_info
        - node_info_from_raw_nat(fsck->entries[nid])
 - do_fsck
  - fsck_init
   - build_nat_area_bitmap
    - fsck->entries = calloc(fsck->nr_nat_entries);

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2019-12-10 08:42:20 -08:00
parent 8c420512fc
commit 65e1898bbe

View File

@ -2126,7 +2126,7 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
struct f2fs_nat_entry raw_nat;
ni->nid = nid;
if (c.func == FSCK) {
if (c.func == FSCK && F2FS_FSCK(sbi)->nr_nat_entries) {
node_info_from_raw_nat(ni, &(F2FS_FSCK(sbi)->entries[nid]));
if (ni->blk_addr)
return;