Commit 93d6fda7 authored by Gao Xiang's avatar Gao Xiang

erofs: fix memory leak on short-lived bounced pages

Both MicroLZMA and DEFLATE algorithms can use short-lived pages on
demand for the overlapped inplace I/O decompression.

However, those short-lived pages are actually added to
`be->compressed_pages`.  Thus, it should be checked instead of
`pcl->compressed_bvecs`.

The LZ4 algorithm doesn't work like this, so it won't be impacted.

Fixes: 67139e36 ("erofs: introduce `z_erofs_parse_in_bvecs'")
Reviewed-by: default avatarYue Hu <huyue2@coolpad.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20231128180431.4116991-1-hsiangkao@linux.alibaba.com
parent 2cc14f52
...@@ -1309,12 +1309,11 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, ...@@ -1309,12 +1309,11 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
put_page(page); put_page(page);
} else { } else {
for (i = 0; i < pclusterpages; ++i) { for (i = 0; i < pclusterpages; ++i) {
page = pcl->compressed_bvecs[i].page; /* consider shortlived pages added when decompressing */
page = be->compressed_pages[i];
if (erofs_page_is_managed(sbi, page)) if (erofs_page_is_managed(sbi, page))
continue; continue;
/* recycle all individual short-lived pages */
(void)z_erofs_put_shortlivedpage(be->pagepool, page); (void)z_erofs_put_shortlivedpage(be->pagepool, page);
WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL); WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment