diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 38531c5e16c6..6562fad27dde 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1583,6 +1583,11 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i, /* Compute min_offs and last. */ last = s->first; + if (!last) { + ret = -EFSCORRUPTED; + goto out; + } + for (; !IS_LAST_ENTRY(last); last = next) { next = EXT4_XATTR_NEXT(last); if ((void *)next >= s->end) {