Use EXT4_INODE_HAS_XATTR_SPACE to check the existence of xattr space, before clear the content in the xattr space #syz test diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index e7a09a99837b..b568232ab871 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1946,7 +1946,8 @@ int ext4_inline_data_truncate(struct inode *inode, int *has_inline) ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS); /* Clear the content in the xattr space. */ - if (inline_size > EXT4_MIN_INLINE_DATA_SIZE) { + if (inline_size > EXT4_MIN_INLINE_DATA_SIZE && + EXT4_INODE_HAS_XATTR_SPACE(inode)) { if ((err = ext4_xattr_ibody_find(inode, &i, &is)) != 0) goto out_error;