]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
f2fs: fix to do sanity check on extent cache correctly
authorChao Yu <chao@kernel.org>
Mon, 9 Jan 2023 03:49:20 +0000 (11:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:50:23 +0000 (13:50 +0100)
[ Upstream commit d48a7b3a72f121655d95b5157c32c7d555e44c05 ]

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

Fixes: 72840cccc0a1 ("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: Sasha Levin <sashal@kernel.org>
fs/f2fs/inode.c

index fb489f55fef3a989a0939a324a26367264e5790f..622eb7963afac51bd47d54ab519e1737ef95c37c 100644 (file)
@@ -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);
@@ -482,6 +476,12 @@ static int do_read_inode(struct inode *inode)
        f2fs_init_read_extent_tree(inode, node_page);
        f2fs_init_age_extent_tree(inode);
 
+       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);