Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: compression: adjust cb->compressed_folios allocation type

In preparation for making the kmalloc() family of allocators type aware,
we need to make sure that the returned type from the allocation matches
the type of the variable being assigned. (Before, the allocator would
always return "void *", which can be implicitly cast to any pointer type.)

The assigned type is "struct folio **" but the returned type will be
"struct page **". These are the same allocation size (pointer size), but
the types don't match. Adjust the allocation type to match the assignment.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Kees Cook and committed by
David Sterba
6f9a8ab7 e08e49d9

+1 -1
+1 -1
fs/btrfs/compression.c
··· 606 606 free_extent_map(em); 607 607 608 608 cb->nr_folios = DIV_ROUND_UP(compressed_len, PAGE_SIZE); 609 - cb->compressed_folios = kcalloc(cb->nr_folios, sizeof(struct page *), GFP_NOFS); 609 + cb->compressed_folios = kcalloc(cb->nr_folios, sizeof(struct folio *), GFP_NOFS); 610 610 if (!cb->compressed_folios) { 611 611 ret = BLK_STS_RESOURCE; 612 612 goto out_free_bio;