@@ -6762,7 +6762,16 @@ static noinline int uncompress_inline(struct btrfs_path *path,
read_extent_buffer(leaf, tmp, ptr, inline_size);
- max_size = min_t(unsigned long, PAGE_CACHE_SIZE, max_size);
+ /*
+ * We can't have max_size > PAGE_CACHE_SIZE because we only
+ * allocated one page. We can't have max_size < PAGE_CACHE_SIZE
+ * because we might extend the file past the end of the page,
+ * so we need to memset the end of the buffer to zero. Since
+ * max_size can't be anything other than PAGE_CACHE_SIZE,
+ * just set it to that value.
+ */
+ WARN_ON(max_size > PAGE_CACHE_SIZE);
+ max_size = PAGE_CACHE_SIZE;
ret = btrfs_decompress(compress_type, tmp, page,
extent_offset, inline_size, max_size);
kfree(tmp);