Skip to content

Commit 12724ba

Browse files
committed
erofs: fix kvcalloc() misuse with __GFP_NOFAIL
As reported by syzbot [1], kvcalloc() cannot work with __GFP_NOFAIL. Let's use kcalloc() instead. [1] https://lore.kernel.org/r/[email protected] Reported-by: [email protected] Fixes: fe3e591 ("erofs: try to leave (de)compressed_pages on stack if possible") Fixes: 4f05687 ("erofs: introduce struct z_erofs_decompress_backend") Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6acd87d commit 12724ba

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/erofs/zdata.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,12 +1032,12 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
10321032

10331033
if (!be->decompressed_pages)
10341034
be->decompressed_pages =
1035-
kvcalloc(be->nr_pages, sizeof(struct page *),
1036-
GFP_KERNEL | __GFP_NOFAIL);
1035+
kcalloc(be->nr_pages, sizeof(struct page *),
1036+
GFP_KERNEL | __GFP_NOFAIL);
10371037
if (!be->compressed_pages)
10381038
be->compressed_pages =
1039-
kvcalloc(pclusterpages, sizeof(struct page *),
1040-
GFP_KERNEL | __GFP_NOFAIL);
1039+
kcalloc(pclusterpages, sizeof(struct page *),
1040+
GFP_KERNEL | __GFP_NOFAIL);
10411041

10421042
z_erofs_parse_out_bvecs(be);
10431043
err2 = z_erofs_parse_in_bvecs(be, &overlapped);
@@ -1085,7 +1085,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
10851085
}
10861086
if (be->compressed_pages < be->onstack_pages ||
10871087
be->compressed_pages >= be->onstack_pages + Z_EROFS_ONSTACK_PAGES)
1088-
kvfree(be->compressed_pages);
1088+
kfree(be->compressed_pages);
10891089
z_erofs_fill_other_copies(be, err);
10901090

10911091
for (i = 0; i < be->nr_pages; ++i) {
@@ -1104,7 +1104,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
11041104
}
11051105

11061106
if (be->decompressed_pages != be->onstack_pages)
1107-
kvfree(be->decompressed_pages);
1107+
kfree(be->decompressed_pages);
11081108

11091109
pcl->length = 0;
11101110
pcl->partial = true;

0 commit comments

Comments
 (0)