From: Ben Hutchings Date: Thu, 29 Nov 2018 19:17:34 +0000 (+0000) Subject: f2fs: Add sanity_check_inode() function X-Git-Tag: v4.14.86~100 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2598fc56ed65f69e303ccee6d5fe756a56f87779;p=users%2Fjedix%2Flinux-maple.git f2fs: Add sanity_check_inode() function This was done as part of commit 5d64600d4f33 "f2fs: avoid bug_on on corrupted inode" upstream, but the specific check that commit added is not applicable to 4.14. Cc: Jaegeuk Kim Cc: Chao Yu Signed-off-by: Ben Hutchings Signed-off-by: Sasha Levin --- diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index b1c0eb433841f..917a6c3d56494 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -180,6 +180,13 @@ void f2fs_inode_chksum_set(struct f2fs_sb_info *sbi, struct page *page) ri->i_inode_checksum = cpu_to_le32(f2fs_inode_chksum(sbi, page)); } +static bool sanity_check_inode(struct inode *inode) +{ + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + + return true; +} + static int do_read_inode(struct inode *inode) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); @@ -281,6 +288,10 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino) ret = do_read_inode(inode); if (ret) goto bad_inode; + if (!sanity_check_inode(inode)) { + ret = -EINVAL; + goto bad_inode; + } make_now: if (ino == F2FS_NODE_INO(sbi)) { inode->i_mapping->a_ops = &f2fs_node_aops;