btrfs: compression: adjust cb->compressed_folios allocation type
authorKees Cook <kees@kernel.org>
Sat, 26 Apr 2025 06:23:29 +0000 (23:23 -0700)
committerDavid Sterba <dsterba@suse.com>
Fri, 2 May 2025 11:19:52 +0000 (13:19 +0200)
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>
fs/btrfs/compression.c

index e7f8ee5d48a4f166533a01dfa3bd9d047c1de2e9..7f11ef559be6e72eb614fd06a46a7f1b4d696683 100644 (file)
@@ -606,7 +606,7 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio)
        free_extent_map(em);
 
        cb->nr_folios = DIV_ROUND_UP(compressed_len, PAGE_SIZE);
-       cb->compressed_folios = kcalloc(cb->nr_folios, sizeof(struct page *), GFP_NOFS);
+       cb->compressed_folios = kcalloc(cb->nr_folios, sizeof(struct folio *), GFP_NOFS);
        if (!cb->compressed_folios) {
                ret = BLK_STS_RESOURCE;
                goto out_free_bio;