Skip to content

Commit 93d6fda

Browse files
committed
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: 67139e3 ("erofs: introduce `z_erofs_parse_in_bvecs'") Reviewed-by: Yue Hu <huyue2@coolpad.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20231128180431.4116991-1-hsiangkao@linux.alibaba.com
1 parent 2cc14f5 commit 93d6fda

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

fs/erofs/zdata.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,12 +1309,11 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
13091309
put_page(page);
13101310
} else {
13111311
for (i = 0; i < pclusterpages; ++i) {
1312-
page = pcl->compressed_bvecs[i].page;
1312+
/* consider shortlived pages added when decompressing */
1313+
page = be->compressed_pages[i];
13131314

13141315
if (erofs_page_is_managed(sbi, page))
13151316
continue;
1316-
1317-
/* recycle all individual short-lived pages */
13181317
(void)z_erofs_put_shortlivedpage(be->pagepool, page);
13191318
WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL);
13201319
}

0 commit comments

Comments
 (0)