diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-07-13 22:59:41 -0700 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-07-15 10:30:03 -0700 |
commit | aac7f4cb42d79f8b621e0002f6818d8414d2db04 (patch) | |
tree | 0abe9f46497152ca3d6310a41179d52e054f2c57 | |
parent | e767223422deb8f209c84db7783b17d0497e61f4 (diff) | |
download | f2fs-tools-aac7f4cb42d79f8b621e0002f6818d8414d2db04.tar.gz |
dump.f2fs: check block address first before reading the block
This should avoid to read out wrong block address.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/dump.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fsck/dump.c b/fsck/dump.c index e472eb7..055ce09 100644 --- a/fsck/dump.c +++ b/fsck/dump.c @@ -482,8 +482,6 @@ void dump_node(struct f2fs_sb_info *sbi, nid_t nid, int force) node_blk = calloc(BLOCK_SZ, 1); ASSERT(node_blk); - dev_read_block(node_blk, ni.blk_addr); - DBG(1, "Node ID [0x%x]\n", nid); DBG(1, "nat_entry.block_addr [0x%x]\n", ni.blk_addr); DBG(1, "nat_entry.version [0x%x]\n", ni.version); @@ -494,6 +492,8 @@ void dump_node(struct f2fs_sb_info *sbi, nid_t nid, int force) goto out; } + dev_read_block(node_blk, ni.blk_addr); + if (ni.blk_addr == 0x0) MSG(force, "Invalid nat entry\n\n"); else if (!is_sit_bitmap_set(sbi, ni.blk_addr)) |