Skip to content

Commit

Permalink
f2fs: fix to do sanity check on extent cache correctly
Browse files Browse the repository at this point in the history
commit d48a7b3 upstream.

In do_read_inode(), sanity_check_inode() should be called after
f2fs_init_read_extent_tree(), fix it.

Fixes: 72840cc ("f2fs: allocate the extent_cache by default")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
chaseyu authored and gregkh committed May 17, 2023
1 parent 18ecffd commit 85eb8b6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fs/f2fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,6 @@ static int do_read_inode(struct inode *inode)
fi->i_inline_xattr_size = 0;
}

if (!sanity_check_inode(inode, node_page)) {
f2fs_put_page(node_page, 1);
f2fs_handle_error(sbi, ERROR_CORRUPTED_INODE);
return -EFSCORRUPTED;
}

/* check data exist */
if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode))
__recover_inline_status(inode, node_page);
Expand Down Expand Up @@ -481,6 +475,12 @@ static int do_read_inode(struct inode *inode)
/* Need all the flag bits */
f2fs_init_read_extent_tree(inode, node_page);

if (!sanity_check_inode(inode, node_page)) {
f2fs_put_page(node_page, 1);
f2fs_handle_error(sbi, ERROR_CORRUPTED_INODE);
return -EFSCORRUPTED;
}

f2fs_put_page(node_page, 1);

stat_inc_inline_xattr(inode);
Expand Down

0 comments on commit 85eb8b6

Please sign in to comment.