diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index fcc89856ab95..1820284a299d 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -1459,6 +1459,14 @@ int ocfs2_validate_inode_block(struct super_block *sb, goto bail; } + if ((le32_to_cpu(di->i_flags) & OCFS2_VALID_FL) && + !(le32_to_cpu(di->i_flags) & OCFS2_ORPHANED_FL) && + le16_to_cpu(di->i_links_count) == 0) { + mlog(ML_ERROR, "Invalid dinode #%llu: VALID but i_links_count=0\n", + (unsigned long long)le64_to_cpu(di->i_blkno)); + rc = -EFSCORRUPTED; + goto bail; + } /* * Errors after here are fatal. */